uses psapi;
{根据进程PID获取程序所在路径的函数}
function GetProcessExePath(PID: Cardinal): string;
var
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
begin
{获取进程句柄}
pHandle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, PID);
{获取进程路径}
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));
CloseHandle(pHandle);
Result := buf;
end;
http://blog.csdn.net/cmdasm/article/details/9961631
时间: 2024-12-22 21:28:54