BobyIsProgress
Member
Hi Guys,
I want to control the number of connection of my user. Like one connection at the time or maybe more.
So I start to search a way to know all the process ID of the windows user session.
This is my code:
I found it there : Get a list of processes (Windows 95/98/2000) | The OpenEdge Hive .
But I want to know wich windows user is the owner of the PID .
Do you know something ?
I want to control the number of connection of my user. Like one connection at the time or maybe more.
So I start to search a way to know all the process ID of the windows user session.
This is my code:
Code:
&GLOB TH32CS_SNAPPROCESS 2
PROCEDURE CreateToolhelp32Snapshot EXTERNAL "kernel32" :
DEFINE INPUT PARAMETER dwFlags AS LONG.
DEFINE INPUT PARAMETER th32ProcessId AS LONG.
DEFINE RETURN PARAMETER hSnapShot AS LONG.
END PROCEDURE.
PROCEDURE Process32First EXTERNAL "kernel32" :
DEFINE INPUT PARAMETER hSnapShot AS LONG.
DEFINE INPUT PARAMETER lpProcessEntry32 AS MEMPTR.
DEFINE RETURN PARAMETER ReturnValue AS LONG.
END PROCEDURE.
PROCEDURE Process32Next EXTERNAL "kernel32" :
DEFINE INPUT PARAMETER hSnapShot AS LONG.
DEFINE INPUT PARAMETER lpProcessEntry32 AS MEMPTR.
DEFINE RETURN PARAMETER ReturnValue AS LONG.
END PROCEDURE.
PROCEDURE CloseHandle EXTERNAL "kernel32" :
DEFINE INPUT PARAMETER hObject AS LONG.
DEFINE RETURN PARAMETER ReturnValue AS LONG.
END PROCEDURE.
RUN ListProcesses.
PROCEDURE ListProcesses:
DEFINE VARIABLE hSnapShot AS INTEGER NO-UNDO.
DEFINE VARIABLE lpPE AS MEMPTR NO-UNDO. /* PROCESSENTRY32 structure */
DEFINE VARIABLE ReturnValue AS INTEGER NO-UNDO.
DEFINE VARIABLE list AS CHARACTER NO-UNDO INITIAL "Process-List:".
/* Create and open SnapShot-list */
RUN CreateToolhelp32Snapshot({&TH32CS_SNAPPROCESS},
0,
OUTPUT hSnapShot).
IF hSnapShot = -1 THEN RETURN.
/* init buffer for lpPE */
SET-SIZE(lpPE) = 336.
PUT-LONG(lpPE, 1) = GET-SIZE(lpPE).
/* Cycle thru process-records */
RUN Process32First(hSnapShot,
lpPE,
OUTPUT ReturnValue).
DO WHILE ReturnValue NE 0:
IF GET-STRING(lpPE, 37) MATCHES "*prowin32.exe*" THEN DO:
MESSAGE GET-STRING(lpPE, 1)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
list = list + "~n".
/* show process identifier (pid): */
list = list + STRING(GET-LONG(lpPE, 9)) + " ".
/* show path and filename of executable: */
list = list + GET-STRING(lpPE, 37).
END.
RUN Process32Next(hSnapShot,
lpPE,
OUTPUT ReturnValue).
END.
/* Close SnapShot-list */
RUN CloseHandle(hSnapShot, OUTPUT ReturnValue).
MESSAGE list
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END PROCEDURE.
I found it there : Get a list of processes (Windows 95/98/2000) | The OpenEdge Hive .
But I want to know wich windows user is the owner of the PID .
Do you know something ?