给出代码 调试通过 给分吧 呵呵!~
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,tlhelp32, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
Ret : BOOL;
ProcessID ,i: integer;
s:string;
begin
i:=0;
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='IEXPLORE.EXE' then
begin
i:=i+1;
ProcessID:=FProcessEntry32.th32ProcessID;
TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,ProcessID),1);
s:='';
end;
Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
Edit1.Text:='一共发现 '+inttostr(i)+'个被杀';
end;
end.