2014年5月7日 星期三

[VB] 無需 OpenProcess 取得進程檔案路徑





調用方式:
MsgBox GetProPath("Explorer.exe") 
函數:
Public Function GetProPath(ProName As String) As String Dim objWMIService As Object Dim colProcesslist As Object Dim objProcess As Object Set objWMIService = CreateObject("winmgmts:{impersonationLevel=Impersonate}!root\cimv2") Set colProcesslist = objWMIService.ExecQuery("select * from win32_process where name=" & Chr(39) & ProName & Chr(39)) For Each objProcess In colProcesslist GetProPath = objProcess.ExecutablePath Next End Function

沒有留言:

張貼留言