function GetProcessExePathByhand(h: HWND): string;
var
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
begin
{先获取进程 ID}
GetWindowThreadProcessId(h, @pid);
{再获取进程句柄}
pHandle := OpenProcess(PROCESS_ALL_ACCESS, False, pid);
{获取进程路径}
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));
// GetMappedFileName (pHandle, 0, buf, Length(buf));
// GetModuleFileName(pHandle,buf,Length(buf));
CloseHandle(pHandle);
Result := buf;
end;
根据窗口句柄获取程序路径
最新推荐文章于 2021-09-16 09:12:24 发布