Код HTML:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, tlhelp32, StdCtrls, Edit, Button;
type
TForm1 = class(TForm)
Button1: TsButton;
Edit1: TsEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function killtask(exefilename: string): integer;
const
process_terminate=$0001;
var
continueloop: bool;
fsnapshothandle: thandle;
fprocessentry32: tprocessentry32;
begin
result := 0;
fsnapshothandle := createtoolhelp32snapshot
(th32cs_snapprocess, 0);
fprocessentry32.dwsize := sizeof(fprocessentry32);
continueloop := process32first(fsnapshothandle,
fprocessentry32);
while integer(continueloop) <> 0 do
begin
if ((uppercase(extractfilename(fprocessentry32.szexefile)) =
uppercase(exefilename))
or (uppercase(fprocessentry32.szexefile) =
uppercase(exefilename))) then
result := integer(terminateprocess(openprocess(
process_terminate, bool(0),
fprocessentry32.th32processid), 0));
continueloop := process32next(fsnapshothandle,
fprocessentry32);
end;
closehandle(fsnapshothandle);
end;
procedure TForm1Button1Click(Sender: TObject);
begin
killtask(Edit1.text);
end;
end.