找回密码
 加入
搜索
查看: 3755|回复: 6

[系统综合] 如何获得完整的进程路径(已解决,期待更多更好的方法出来)

  [复制链接]
发表于 2011-2-21 18:10:17 | 显示全部楼层 |阅读模式
本帖最后由 gzh888666 于 2011-2-22 15:48 编辑

_WinAPI_GetModuleFileNameEx
获取进程路径时,很多的进程路径无法获得。
问一下有没有什么办法获得每个进程的路径呢?
最好没有任何遗漏的exe进程!
如smss.exe 、audiodg.exe等等
发表于 2011-2-21 19:17:44 | 显示全部楼层
Dim $procName="chrome.exe"
Dim $ProcID=ProcessExists($procName) 
;MsgBox(0,'',$ProcID)
If ($ProcID) Then
    MsgBox(0, '', _ProcessGetLocation($ProcID))

EndIf


Func _ProcessGetLocation($iPID)
    Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
    If $aProc[0] = 0 Then Return SetError(1, 0, '')
    Local $vStruct = DllStructCreate('int[1024]')
    DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 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
参考:http://www.autoitscript.com/foru ... _306485#entry306485
发表于 2011-2-21 19:19:06 | 显示全部楼层
测试Dim $procName="smss.exe"
同样可以获得路径,但是没有盘符。
 楼主| 发表于 2011-2-21 20:28:27 | 显示全部楼层
回复 2# bsmagic


    2楼这个也不全

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-2-21 21:51:33 | 显示全部楼层
#Include <WinAPIEx.au3>
 #include <array.au3>
 
$list = ProcessList()
ReDim $list[UBound($list)][3]
$hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, 1)
 
for $i=1 to $list[0][0] 
                $list[$i][2]=_WinAPI_GetProcessFileName($list[$i][1])
Next
 
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, 2)
_WinAPI_CloseHandle($hToken)

_arraydisplay($list)
 楼主| 发表于 2011-2-22 14:15:11 | 显示全部楼层
回复 5# 3mile


    相当不错了!谢谢,只有audiodg.exe没有获取到
发表于 2011-3-11 10:33:31 | 显示全部楼层
看着那是相当的复杂哦
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 12:29 , Processed in 0.097314 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表