LVAC Posted August 17, 2009 Share Posted August 17, 2009 I found on this forum a UDF for Enumarating ThreadsBut that UDF enumarates all threads of all processes. I want to get threads of a specify process (not all processes). Can you help me? Link to comment Share on other sites More sharing options...
Andreik Posted August 17, 2009 Share Posted August 17, 2009 I found something on forum. Use _GetAllProcessThreads with PID of your process. #include <WinAPi.au3> #include <Array.au3> Global Const $TH32CS_SNAPTHREAD = 0x00000004 Global Const $THREADENTRY32 = "dword dwSize;dword cntUsage;dword th32ThreadId;dword th32OwnerProcessID;long tpBasePri;long tpDeltaPri;dword dwFlags;" Func _GetAllProcessThreads($iPid) Local $call = DllCall("Kernel32.dll", "ptr", "CreateToolhelp32Snapshot", "dword", $TH32CS_SNAPTHREAD, "dword", 0) Local $handle = $call[0] Local $RetArr[1][3] ;~ ConsoleWrite("Handle: " & $handle & @CRLF) Local $te32 = DllStructCreate($THREADENTRY32) DllStructSetData($te32, "dwSize", DllStructGetSize($te32)) $call = DllCall("Kernel32.dll", "int", "Thread32First", "ptr", $handle, "ptr", DllStructGetPtr($te32)) If DllStructGetData($te32, "th32OwnerProcessID") = $iPid Then _GetAllThreads_ArrHelper($RetArr, $te32) Do $call = DllCall("Kernel32.dll", "int", "Thread32Next", "ptr", $handle, "ptr", DllStructGetPtr($te32)) If Not $call[0] Then ExitLoop If DllStructGetData($te32, "th32OwnerProcessID") = $iPid Then _GetAllThreads_ArrHelper($RetArr, $te32) Until True And False _ArrayDelete($RetArr, 0) _WinAPI_CloseHandle($handle) Return $RetArr EndFunc ;==>_GetAllProcessThreads Func _GetAllThreads_ArrHelper(ByRef $arr, $TE32_Struct) Local $ub = UBound($arr) ReDim $arr[$ub + 1][3] $arr[$ub][0] = DllStructGetData($TE32_Struct, "th32ThreadId") $arr[$ub][1] = DllStructGetData($TE32_Struct, "th32OwnerProcessID") $arr[$ub][2] = DllStructGetData($TE32_Struct, "tpBasePri") EndFunc ;==>_GetAllThreads_ArrHelper When the words fail... music speaks. Link to comment Share on other sites More sharing options...
LVAC Posted August 19, 2009 Author Share Posted August 19, 2009 Oh no! I found that the array displayed when use Arraydisplay() is all way have only [0] row >_ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now