imani Posted February 16, 2008 Share Posted February 16, 2008 is there any code to get the path of a running process from it's PID Link to comment Share on other sites More sharing options...
rasim Posted February 16, 2008 Share Posted February 16, 2008 is there any code to get the path of a running process from it's PID$GetPath = _ProcessGetLocation("notepad.exe") If $GetPath = -1 Then MsgBox(16, "Error", "Unable get process path") Else MsgBox(0, "Success", $GetPath) EndIf Func _ProcessGetLocation($sProc = @ScriptFullPath) Local $iPID = ProcessExists($sProc) If $iPID = 0 Then Return SetError(1, 0, -1) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, -1) Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int*', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc Link to comment Share on other sites More sharing options...
BigDod Posted February 16, 2008 Share Posted February 16, 2008 If you had bothered to search you would have found This Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
imani Posted February 16, 2008 Author Share Posted February 16, 2008 Thanks for the code Link to comment Share on other sites More sharing options...
imani Posted February 17, 2008 Author Share Posted February 17, 2008 $GetPath = _ProcessGetLocation("notepad.exe") If $GetPath = -1 Then MsgBox(16, "Error", "Unable get process path") Else MsgBox(0, "Success", $GetPath) EndIf Func _ProcessGetLocation($sProc = @ScriptFullPath) Local $iPID = ProcessExists($sProc) If $iPID = 0 Then Return SetError(1, 0, -1) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, -1) Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int*', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc Rasim could you please tell me from where you have got information about handling windows dll files to call for specific functions , I mean any web site that has these like resources Link to comment Share on other sites More sharing options...
FreeFry Posted February 17, 2008 Share Posted February 17, 2008 Microsoft Developer Network Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 17, 2008 Moderators Share Posted February 17, 2008 Rasim could you please tell me from where you have got information about handling windows dll files to call for specific functions , I mean any web site that has these like resourcesHe got his information from: http://www.autoitscript.com/forum/index.ph...st&p=306485But if you want to use standard DLL params with DllCall() FreeFry has provided the correct link for the knowledge base. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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