您的位置:程序门 -> delphi -> windows sdk/api



怎样判断进程列表中有没有名称为"rar.exe"的进程?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


怎样判断进程列表中有没有名称为'rar.exe'的进程?[已结贴,结贴人:lunyx]
发表于:2008-01-09 15:58:22 楼主
怎样判断进程列表中有没有名称为'rar.exe'的进程?我用findwindow不成功,help!
发表于:2008-01-09 15:59:441楼 得分:1
baidu到处有,用psapi或进程快照
发表于:2008-01-09 16:07:352楼 得分:0
找了好久,没找到一个能经受考验的
发表于:2008-01-09 16:09:543楼 得分:39
delphi(pascal) code
[delphi函数] 查找进程并显示在memo中2007-05-11 08:07 a.m.uses 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);//在调用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!');
发表于:2008-01-09 16:45:494楼 得分:0
uses   tlhelp32;

procedure   tform1.button1click(sender:   tobject);
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;


如果进程存在,则会弹出提示。


快速检索

最新资讯
热门点击