怎样判断进程列表中有没有名称为'rar.exe'的进程?我用findwindow不成功,help!
解决方案 »
- 求一段直接赋值的代码!?
- 怎样动态画线段
- 多线程在串口通信中的运用问题?
- ##Delphi园地最新更新,请大家继续推荐Delphi经典编程资源##
- 第一次用installshield制作安装文件,请指教
- random 函数 怎么设定随机数范围啊?
- delphi7 的websnap有问题?
- 如何在delphi中实现TDBComboBox从一个编码表中读数据!!!!!
- 如何将文本文件内的数据导入数据库?急!!在线等待!
- 我37了,64年,龙,多少人比我大的同僚在这里晃悠?
- delphi调用 c++的dll的__stdcall函数 启动就抱错
- delphi 调用webservice 出现Unauthorized (401)错误
function FindProcess(AFileName: string): boolean;
var
hSnapshot: THandle;//用于获得进程列表
lppe: TProcessEntry32;//用于查找进程
Found: Boolean;//用于判断进程遍历是否完成
begin
Result :=False;
hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);//获得系统进程列表
lppe.dwSize := SizeOf(TProcessEntry32);//在调用Process32First API之前,需要初始化lppe记录的大小
Found := Process32First(hSnapshot, lppe);//将进程列表的第一个进程信息读入ppe记录中
while Found do
begin
if ((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName)) or (UpperCase(lppe.szExeFile )=UpperCase(AFileName))) then
begin
Result :=True;
end;
Found := Process32Next(hSnapshot, lppe);//将进程列表的下一个进程信息读入lppe记录中
end;
end;
Usage: if FindProcess('rar.exe') then memo1.Lines.Add('rar.exe!');
var
lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(Hand,lppe);
while found do
begin
if SameText('rar.exe',StrPas(lppe.szExeFile)) then//在这里判断是否存在
showmessage('rar.exe进程存在!');
found := Process32Next(Hand,lppe);
end;
end;
如果进程存在,则会弹出提示。