Hi,
Can anyone assist me with finding the ProcessID for "explorer.exe". ? (I am wanting to know the PID for this single executable and nothing else.)
Any sample code would be useful.
Thanks,
Al.
Printable View
Hi,
Can anyone assist me with finding the ProcessID for "explorer.exe". ? (I am wanting to know the PID for this single executable and nothing else.)
Any sample code would be useful.
Thanks,
Al.
I used the following API's to get me the data of all processes on the computer. Here's what i used
VB Code:
'consts Private Const TH32CS_SNAPPROCESS = &H2 ' Types Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long ' This process th32DefaultHeapID As Long th32ModuleID As Long ' Associated exe cntThreads As Long th32ParentProcessID As Long ' This process's parent process pcPriClassBase As Long ' Base priority of process threads dwFlags As Long szExeFile As String * 260 ' MAX_PATH End Type ' Functions used Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" ( _ ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Private Declare Function Process32First Lib "kernel32" ( _ ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "kernel32" ( _ ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long 'Start of function or sub Dim hWND As Long Dim ProData As PROCESSENTRY32 Dim Ret As Long Ret = 1 ProData.dwSize = Len(ProData) ' sets the ProData.dwSize to the size of the structure hWND = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) ' Create snapshot of the first process Ret = Process32First(hWND, ProData) ' Gets handle of first process Do Until Ret = 0 ' get the rest of the processes debug.print ProData.szExeFile debug.print ProData.th32ProcessID Ret = Process32Next(hWND, ProData) ' gets next Process handle Loop 'end of sub or function
hope this helps. This gets all process ID's and the names so you just have to filter for Explorer.exe