This will list all running processes (that includes EXE's, DLL's etc). Add a List box (List1) and a command button to a form. Paste this code into a moduleThen place this in the click event of the command button on the formVB Code:
Public Const TH32CS_SNAPPROCESS As Long = 2& Public Const MAX_PATH As Integer = 260 Public Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Public Declare Function ProcessFirst Lib "Kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Public Declare Function ProcessNext Lib "Kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Public Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)You can then modify it to suit what you need...for example to see if IE is open, modify the Do Loop like so...VB Code:
Dim hSnapShot As Long Dim uProcess As PROCESSENTRY32 Dim r As Long hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) If hSnapShot = 0 Then Exit Sub End If uProcess.dwSize = Len(uProcess) r = ProcessFirst(hSnapShot, uProcess) Do While r List1.AddItem uProcess.szExeFile r = ProcessNext(hSnapShot, uProcess) Loop Call CloseHandle(hSnapShot)VB Code:
Do While r If InStr(1, uProcess.szExeFile, "IEXPLORE.EXE", vbTextCompare) > 0 Then MsgBox "Internet Explorer is running!", vbInformation End If r = ProcessNext(hSnapShot, uProcess) Loop




Reply With Quote