here's some code to get the list of running process IDs, but there's a slight 'issue' in that I seem to be missing something with the process name (it says 'illegal type conversion'). I think the Process32First/Next functions are overwriting something?
You should find the process in this list IDs match those in Task Manager, at least!
; -----------------------------------------------------------------------------
; Create or open existing kernel32.decls file in userlibs folder and place
; these lines in it (uncommented!)...
; -----------------------------------------------------------------------------
;
; .lib "kernel32.dll"
;
; CreateToolhelp32Snapshot% (flags, th32processid)
; Process32First% (snapshot, entry*)
; Process32Next% (snapshot, entry*)
; CloseHandle% (object)
;
; -----------------------------------------------------------------------------
Const MAX_PATH = 264
Const TH32CS_SNAPHEAPLIST = $1
Const TH32CS_SNAPPROCESS = $2
Const TH32CS_SNAPTHREAD = $4
Const TH32CS_SNAPMODULE = $8
Const TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE
Const TH32CS_INHERIT = $80000000
Const INVALID_HANDLE_VALUE = -1
Const SizeOf_PE32 = 296
Type PROCESSENTRY32
Field dwSize
Field cntUsage
Field th32ProcessID
Field th32DefaultHeapID
Field th32ModuleID
Field cntThreads
Field th32ParentProcessID
Field pcPriClassBase
Field dwFlags
Field szExeFile$ [MAX_PATH]
End Type
snap = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0)
If snap
Proc32.PROCESSENTRY32 = New PROCESSENTRY32
Proc32\dwSize = SizeOf_PE32
If Process32First (snap, Proc32)
Print "Process ID: " + Proc32\th32ProcessID
While Process32Next (snap, Proc32)
Print "Process ID: " + Proc32\th32ProcessID
Print "----> Parent process ID: " + Proc32\th32ParentProcessID
Print Proc32\szExeFile ; Illegal type conversion?
Wend
EndIf
CloseHandle (snap)
EndIf
Print "Hit ENTER..."
Input ()
End
;-------------- end of code---------------------
thanks,
best,
mike
You should find the process in this list IDs match those in Task Manager, at least!
; -----------------------------------------------------------------------------
; Create or open existing kernel32.decls file in userlibs folder and place
; these lines in it (uncommented!)...
; -----------------------------------------------------------------------------
;
; .lib "kernel32.dll"
;
; CreateToolhelp32Snapshot% (flags, th32processid)
; Process32First% (snapshot, entry*)
; Process32Next% (snapshot, entry*)
; CloseHandle% (object)
;
; -----------------------------------------------------------------------------
Const MAX_PATH = 264
Const TH32CS_SNAPHEAPLIST = $1
Const TH32CS_SNAPPROCESS = $2
Const TH32CS_SNAPTHREAD = $4
Const TH32CS_SNAPMODULE = $8
Const TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE
Const TH32CS_INHERIT = $80000000
Const INVALID_HANDLE_VALUE = -1
Const SizeOf_PE32 = 296
Type PROCESSENTRY32
Field dwSize
Field cntUsage
Field th32ProcessID
Field th32DefaultHeapID
Field th32ModuleID
Field cntThreads
Field th32ParentProcessID
Field pcPriClassBase
Field dwFlags
Field szExeFile$ [MAX_PATH]
End Type
snap = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0)
If snap
Proc32.PROCESSENTRY32 = New PROCESSENTRY32
Proc32\dwSize = SizeOf_PE32
If Process32First (snap, Proc32)
Print "Process ID: " + Proc32\th32ProcessID
While Process32Next (snap, Proc32)
Print "Process ID: " + Proc32\th32ProcessID
Print "----> Parent process ID: " + Proc32\th32ParentProcessID
Print Proc32\szExeFile ; Illegal type conversion?
Wend
EndIf
CloseHandle (snap)
EndIf
Print "Hit ENTER..."
Input ()
End
;-------------- end of code---------------------
thanks,
best,
mike