endlesslove_1998

Get paths of all processes

Sep 28th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.80 KB | None | 0 0
  1.  
  2. Local $aProcessList = ProcessList()
  3. For $i = 1 To $aProcessList[0][0]
  4.     ConsoleWrite(_ProcessGetLocation($aProcessList[$i][1]) & @CRLF)
  5. Next
  6.  
  7. ; Larry
  8. Func _ProcessGetLocation($iPID)
  9.     Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
  10.     If $aProc[0] = 0 Then Return SetError(1, 0, '')
  11.     Local $vStruct = DllStructCreate('int[1024]')
  12.     DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
  13.     Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
  14.     If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
  15.     Return $aReturn[3]
  16. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment