delphi根据进程PID获取程序所在路径的函数(用OpenProcess取得句柄,用GetModuleFileNameEx取得程序名)

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

上一篇:windows 8 Metro 设置选中ListViewItem 的样式


下一篇:leetcode 388.Lonest Absolute File Path