//不光可以用文件名来探测进程的存在,还能列出所有的进程列表。
uses TLHelp32;
procedure TForm1.Button1Click(Sender: TObject);
var
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
Ret : BOOL;
ProcessID : integer;
s:string;
begin
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
Ret:=Process32First(FSnapshotHandle,FProcessEntry32);
Memo1.clear;
while Ret do
begin
Memo1.lines.add(FProcessEntry32.szExeFile);
s:=ExtractFileName(FProcessEntry32.szExeFile);
if s='WoW.exe' then
begin
showmessage('魔兽世界正在运行');
end;
Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
end;
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
Ret : BOOL;
ProcessID : integer;
s:string;
begin
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
Ret:=Process32First(FSnapshotHandle,FProcessEntry32);
Memo1.clear;
while Ret do
begin
Memo1.lines.add(FProcessEntry32.szExeFile);
s:=ExtractFileName(FProcessEntry32.szExeFile);
if s='WoW.exe' then
begin
showmessage('魔兽世界正在运行');
end;
Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
end;
本文介绍了一个使用Delphi编写的简单程序,该程序能够通过创建工具帮助快照来获取当前系统中所有正在运行的进程列表,并检查特定进程是否正在运行。
1万+

被折叠的 条评论
为什么被折叠?



