DWORD GetModuleFileNameEx(HANDLE hProcess,HMODULE hModule,LPTSTR lpFilename,DWORD nSize)
参数:hProcess是目标进程的句柄、
hModule是目标模块的句柄(当此参数为NULL时函数返回的是进程可执行文件的路径)、
lpFilename是存放路径的字符串缓冲区、
nSize表示缓冲区的大小。
方案一:dllcall
WinGet,PID,PID,A
NowRoute:=GetModuleFileNameEx(PID)
SplitPath,NowRoute,NowFile,NowDir
Run,% "Explorer.exe /select, " NowRoute
Return
;~ ========= 获取进程路径 =========
GetModuleFileNameEx( p_pid )
{
if A_OSVersion in WIN_95,WIN_98,WIN_ME
{
MsgBox, This Windows version (%A_OSVersion%) is not supported.
return
}
h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid )
if ( ErrorLevel or h_process = 0 )
return
name_size = 255
VarSetCapacity( name, name_size )
result := DllCall( "psapi.dll\GetModuleFileNameExW", "uint", h_process, "uint", 0, "str", name, "uint", name_size )
DllCall( "CloseHandle", h_process )
return, name
}
方案二:AutoHotkey的简单之美
WinGet, _ProcessPath, ProcessPath, A
Run,% "Explorer.exe /select, " _ProcessPath
return