通过进程ID获取进程名

uses TLhelp32
function GetProcessNameById(const AID: Integer): String;
var     
h:thandle;     
f:boolean;     
lppe:tprocessentry32;
begin     
Result := '';     
h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);     
lppe.dwSize := sizeof(lppe);     
f := Process32First(h, lppe);     
while integer(f) <> 0 do     
begin       
if Integer(lppe.th32ProcessID) = AID then       
begin         
Result:= StrPas(lppe.szExeFile);         
break;       
end;       
f := Process32Next(h, lppe);     
end;
end

posted on 2010-10-18 13:32  Delphi7456  阅读(3210)  评论(0编辑  收藏  举报

导航