本文整理自网络,侵删。
在网上找了半天,也没找到DELPHI版的PID->NAME的代码。。。找到了一份C++的,翻译成了DELPHI的,发BLOG上,方便以后查找使用。。。。
function ProcessIdToName(PID:DWORD):string;
var
hSnapshot:THandle;
PE:PROCESSENTRY32;
begin
Result:='';
hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize:= sizeof(PROCESSENTRY32);
if Process32First(hSnapshot, pe) <> False then
begin
while (Process32Next(hSnapshot, pe)) do
begin
if (pe.th32ProcessID = PID) then
begin
Result:=pe.szExeFile;
Break;
end;
end;
end;
end;
相关阅读 >>
Delphi研究之驱动开发篇(六)--利用section与用户模式程
Delphi 用 getenvironmentvariable 获取常用系统环境变量
Delphi readprocessmemory 输入进程id 输入读取地址
更多相关阅读请进入《Delphi》频道 >>