akorx Posted July 30, 2009 Posted July 30, 2009 Hi ! I'm french, so don't laugh about my bad english... >_< I've got a question : how can i find informations about a process that is running ? an example : i have 2 notepad.exe on my computer (for example one in c:\windows\ and another in c:\windows\system32) and one is running... which of the 2 processes has been loaded ? AkorxMail akorx@yahoo.fr
99ojo Posted July 30, 2009 Posted July 30, 2009 (edited) Hi ! I'm french, so don't laugh about my bad english... >_< I've got a question : how can i find informations about a process that is running ? an example : i have 2 notepad.exe on my computer (for example one in c:\windows\ and another in c:\windows\system32) and one is running... which of the 2 processes has been loaded ? Hi, try this: ;#RequireAdmin ; only for Vista -> Remove the ; before the# Global $hPsAPI = DllOpen("Psapi.dll") Global $hKernel = DllOpen("Kernel32.dll") $aProcList = ProcessList ("Notepad.exe") For $i = 1 To $aProcList [0][0] MsgBox(0,"", "Explorer:" & @CRLF & _ProcessGetPath($aProcList [$i] [1])) Next Func _ProcessGetPath($hPID) If IsString($hPID) Then $hPID = ProcessExists($hPID) If $hPID = 0 Then Return SetError(1,0,'') Local $sPath = DllStructCreate("char[1000]") Local $hProcess = DllCall($hKernel, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $hPID) DllCall($hPsAPI, "long", "GetModuleFileNameEx", "long", $hProcess[0], "int", 0, "ptr", DllStructGetPtr($sPath), "long", DllStructGetSize($sPath)) DllCall($hKernel, "int", "CloseHandle", "hwnd", $hProcess[0]) Return DllStructGetData($sPath, 1) EndFunc ;-)) Stefan Edited July 30, 2009 by 99ojo
akorx Posted July 30, 2009 Author Posted July 30, 2009 Hi, try this: ;#RequireAdmin ; only for Vista -> Remove the ; before the# Global $hPsAPI = DllOpen("Psapi.dll") Global $hKernel = DllOpen("Kernel32.dll") $aProcList = ProcessList ("Notepad.exe") For $i = 1 To $aProcList [0][0] MsgBox(0,"", "Explorer:" & @CRLF & _ProcessGetPath($aProcList [$i] [1])) Next Func _ProcessGetPath($hPID) If IsString($hPID) Then $hPID = ProcessExists($hPID) If $hPID = 0 Then Return SetError(1,0,'') Local $sPath = DllStructCreate("char[1000]") Local $hProcess = DllCall($hKernel, "int", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $hPID) DllCall($hPsAPI, "long", "GetModuleFileNameEx", "long", $hProcess[0], "int", 0, "ptr", DllStructGetPtr($sPath), "long", DllStructGetSize($sPath)) DllCall($hKernel, "int", "CloseHandle", "hwnd", $hProcess[0]) Return DllStructGetData($sPath, 1) EndFunc ;-)) Stefan That's perfect !!! nothing to say... Thanks AkorxMail akorx@yahoo.fr
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