怎么检查某个程序是否在进程里。 怎么检查某个程序是否在进程里啊,比如qq.exe。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是引用大富翁的代码:uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,tlhelp32,stdCtrls, ExtCtrls;//注意加上tlhelp32这个单元;type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; Timer1: TTimer; ListBox2: TListBox; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); private procedure processlist(var prolist:tlist);//自定义函数列举所有的进程; procedure exitcode ;//自定义函数终止进程; { Private declarations } public { Public declarations } end;type tproinfo=recordfilename:string;proid:dword;end;proinfo=^tproinfo;//自定义记录用来记录进程的文件名和ID;var Form1: TForm1; curr:tlist; temp,b,a1:integer;implementation{$R *.DFM}procedure TForm1.processlist(var prolist: tlist);var p:proinfo; ok:bool; prolisthandle:thandle; prostruct:tprocessentry32; //记录进程的数据结构;beginprolist:=tlist.Create ;prolist.Clear ;prolisthandle:=createtoolhelp32snapshot(th32cs_snapprocess,0);prostruct.dwSize :=sizeof(prostruct);ok:=process32first(prolisthandle,prostruct);//发现第一个进程;while integer(ok)<>0 dobeginnew(p);p.filename :=prostruct.szExeFile ;p.proid :=prostruct.th32ProcessID ;prolist.Add (p);ok:=process32next(prolisthandle,prostruct);//发现下一个进程;end;end;procedure TForm1.FormCreate(Sender: TObject);vara:string;f:textfile;beginlistbox1.Clear;listbox2.Clear;if fileexists('D:\Program Files\text1.txt') thenbegin //该文件记录你所想禁止运行的程序的路径;assignfile(f,'D:\Program Files\text1.txt');reset(f);while not eof(f) dobeginreadln(f,a);a:=uppercase(a); //转化成大写字母;listbox2.Items.Add (a); //记录所有被禁止运行程序的路径;end;closefile(f)endelse application.Terminate ;end;procedure Tform1.exitcode;var h:thandle;a:dword;p:proinfo;beginbeginp:=curr.items[b]; //指向禁止运行的进程的数据结构;h:=openprocess(process_all_access,true,p.proid);getexitcodeprocess(h,a); //得到进程退出代码;terminateprocess(h,a) ; //终止进程end;end;procedure TForm1.Timer1Timer(Sender: TObject);var i:integer;p:proinfo;beginlistbox1.Clear ;processlist(curr); //调用进程列举的函数;for i:=0 to curr.Count-1 dobeginnew(p);p:=curr.Items[i];listbox1.Items.Add(p.filename); //记录所有的进程的路径;end; //listbox2是记录所有禁止运行的程序的路径;for i:=0 to listbox2.Items.Count-1 doif (listbox1.Items.IndexOf(listbox2.Items.Strings[i])>=0) thenbeginb:=listbox1.Items.IndexOf(listbox2.Items.Strings[i]);exitcode;//调用终止进程的函数;end;end;end. 多个数组互相组合,但不能出现重复. 帮帮我 看了好多帖子也没有头绪 请教,如何让程序忽略所有的错误,不弹出报错的提示???谢谢!! 如何实现DBGrid的单元格可以下拉选择?并且dbgrid的数据修改之后如何保存到数据库中? 超难问题,求助高手! 怎样自己定义消息窗口?有没有这种模板? 请问谁有关于installshield的比较详细的资料? ●怎样控制鼠标?◆ sql 问题??? TTreeView显示地区资料,数据库应如何处理?具体怎么算? 40分~给前4位~ 请问斑竹~
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,tlhelp32,stdCtrls, ExtCtrls;//注意加上tlhelp32这个单元;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Timer1: TTimer;
ListBox2: TListBox;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
procedure processlist(var prolist:tlist);//自定义函数列举所有的进程;
procedure exitcode ;//自定义函数终止进程;
{ Private declarations }
public
{ Public declarations }
end;
type tproinfo=record
filename:string;
proid:dword;
end;proinfo=^tproinfo;//自定义记录用来记录进程的文件名和ID;var
Form1: TForm1;
curr:tlist;
temp,b,a1:integer;
implementation{$R *.DFM}
procedure TForm1.processlist(var prolist: tlist);
var p:proinfo;
ok:bool;
prolisthandle:thandle;
prostruct:tprocessentry32; //记录进程的数据结构;
begin
prolist:=tlist.Create ;
prolist.Clear ;
prolisthandle:=createtoolhelp32snapshot(th32cs_snapprocess,0);
prostruct.dwSize :=sizeof(prostruct);
ok:=process32first(prolisthandle,prostruct);//发现第一个进程;
while integer(ok)<>0 do
begin
new(p);
p.filename :=prostruct.szExeFile ;
p.proid :=prostruct.th32ProcessID ;
prolist.Add (p);
ok:=process32next(prolisthandle,prostruct);//发现下一个进程;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
a:string;
f:textfile;
begin
listbox1.Clear;
listbox2.Clear;
if fileexists('D:\Program Files\text1.txt') then
begin //该文件记录你所想禁止运行的程序的路径;
assignfile(f,'D:\Program Files\text1.txt');
reset(f);
while not eof(f) do
begin
readln(f,a);
a:=uppercase(a); //转化成大写字母;
listbox2.Items.Add (a); //记录所有被禁止运行程序的路径;
end;
closefile(f)
end
else application.Terminate ;end;
procedure Tform1.exitcode;
var h:thandle;
a:dword;
p:proinfo;begin
begin
p:=curr.items[b]; //指向禁止运行的进程的数据结构;
h:=openprocess(process_all_access,true,p.proid);
getexitcodeprocess(h,a); //得到进程退出代码;
terminateprocess(h,a) ; //终止进程
end;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var i:integer;
p:proinfo;
begin
listbox1.Clear ;
processlist(curr); //调用进程列举的函数;
for i:=0 to curr.Count-1 do
begin
new(p);
p:=curr.Items[i];
listbox1.Items.Add(p.filename); //记录所有的进程的路径;
end; //listbox2是记录所有禁止运行的程序的路径;
for i:=0 to listbox2.Items.Count-1 do
if (listbox1.Items.IndexOf(listbox2.Items.Strings[i])>=0) then
begin
b:=listbox1.Items.IndexOf(listbox2.Items.Strings[i]);
exitcode;//调用终止进程的函数;
end;
end;
end.