Option expedition
Const max_path = 260const th32cs_snapprocess = 2 &
Private Type PROCESSENTRY32 lSize As Long lUsage As Long lProcessId As Long lDefaultHeapId As Long lModuleId As Long lThreads As Long lParentProcessId As Long lPriClassBase As Long lFlags As Long sExeFile As String * MAX_PATHEnd Type
Private Declare Sub CloseHandle Lib "Kernel32" (Byval HPass As Long)
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _ Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, _ ByVal lProcessId As Long) As Long Private Declare Function ProcessFirst Lib "kernel32" _ Alias "Process32First" (ByVal hSnapshot As Long, _ uProcess As PROCESSENTRY32 ) As Long Private Declare Function ProcessNext Lib "kernel32" _ Alias "Process32Next" (ByVal hSnapshot As Long, _ uProcess As PROCESSENTRY32) As LongPrivate Sub Form_Load () Dim sExeName As StringDim sPid As StringDim sParentPid As StringDim lSnapShot As LongDim r As LongDim uProcess As processentry32
lSnapShot = CreateToolhelpSnapshot (TH32CS_SNAPPROCESS, 0 &) If lSnapShot <> 0 Then With MSFLEXGRID1 .Clear .Rows = 1 .Cols = 4 '.FixedCols = 1' .FixedRows = 0 .TextMatrix (0, 0) = "Module Name" .TextMatrix (0, 1) = "Process ID" .TextMatrix (0, 2) = "Parent" & vbcrlf & "process" .TextMatrix (0, 3) = "threads ".Rowheight (0) = 400 .COLWIDTH (0) = 4200 .ColWidth (1) = 950 .ColWidth (2) = 950 .ColWidth (3) = 775 .ColAlignment (0) = flexAlignLeftBottom .ColAlignment (1) = flexAlignLeftBottom .ColAlignment (2) = flexAlignLeftBottom .ColAlignment (3) = flexAlignLeftBottom uProcess.lSize = Len (uProcess) r = ProcessFirst (lSnapShot, uProcess) Do While r sExeName = Left (uProcess.sExeFile, InStr (1, uProcess.sExeFile, vbNullChar) - 1) sPid = Hex $ (uProcess.lProcessId) SparentPid = Hex $ (Uprocess.lparentProcessid) .addItem Sexename & Vbtab & Spid & Vbtab &_ Sparentpid & Vbtab & CSTR (Uprocess.lthreads) R = processNext (Lsnapshot, Uprocess) loop closehandle (lsnapshot) End Withend IFEND SUB