Delphi判断进程是否存在(使用CreateToolhelp32Snapshot)
program Project2;
uses
windows,TLHelp32;
function FindProcess(AFileName:string):boolean;
var
hSnapshot:THandle;
lppe:TProcessEntry32;
Found:Boolean;
begin
Result:=False;
hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
lppe.dwSize:=SizeOf(TProcessEntry32);
Found:=Process32First(hSnapshot,lppe);
while Found do
begin
if(lppe.szExeFile = AFileName) then Result:=True;
Found:=Process32Next(hSnapshot,lppe);
end;
end;
begin
if FindProcess(‘QQ.exe‘) then
MessageBox(0, PChar(‘QQ存在‘), PChar(‘提示‘), MB_OK);
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/61173.html