vbrobinson
asked on
List the Processes
Hello Experts
How do I list the proceses that are running on Windows 9X?
Thanx,
Robinson
How do I list the proceses that are running on Windows 9X?
Thanx,
Robinson
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works like a charm!
Thanx Ruchi & Wsh2
Thanx Ruchi & Wsh2
<laughing>.. You gave Ruchi points for hyperlinks? Oh well.. Congrats Ruchi.. <smile>
<----- Begin Code ----->
Option Explicit
Const MAX_PATH = 260
Const 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_PATH
End Type
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" _
Alias "CreateToolhelp32Snapshot"
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 Long
Private Sub Form_Load()
Form1.Left = Screen.Width * 0.1
Form1.Top = Screen.Height * 0.1
Form1.Width = Screen.Width * 0.8
Form1.Height = Screen.Height * 0.8
Dim sExeName As String
Dim sPid As String
Dim sParentPid As String
Dim lSnapShot As Long
Dim r As Long
Dim uProcess As PROCESSENTRY32
lSnapShot = CreateToolhelpSnapshot(TH3
If lSnapShot <> 0 Then
With MSFlexGrid1
.Left = ScaleLeft
.Top = ScaleTop
.Width = ScaleWidth
.Height = ScaleHeight
.Clear
.Cols = 4
.Rows = 1
.TextMatrix(0, 0) = "Module"
.TextMatrix(0, 1) = "ProcessId"
.TextMatrix(0, 2) = "Parent Process"
.TextMatrix(0, 3) = "Threads"
.RowHeight(0) = 400
.ColWidth(0) = ScaleWidth * 0.55
.ColWidth(1) = ScaleWidth * 0.15
.ColWidth(2) = ScaleWidth * 0.15
.ColWidth(3) = ScaleWidth * 0.1
.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.lParentProce
.AddItem sExeName & vbTab & sPid & vbTab & _
sParentPid & vbTab & CStr(uProcess.lThreads)
r = ProcessNext(lSnapShot, uProcess)
Loop
CloseHandle (lSnapShot)
End With
End If
End Sub
<----- End Code ----->
Code Author: Anon