type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
killhandle,h:hwnd;
val:boolean;
processstruc:tprocessentry32;
killword:dword;
processid:longint;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
h:=createtoolhelp32snapshot(th32cs_snapprocess,0);
processstruc.dwSize:=sizeof(processstruc);
val:=process32first(h,processstruc);
while val do
begin
if processstruc.szExeFile='Winamp.exe' then
begin
killhandle:=openprocess(process_all_access,true,processstruc.th32ProcessID);
getexitcodeprocess(killhandle,killword);
terminateprocess(killhandle,killword);
end;
listbox1.Items.Add(processstruc.szExeFile);
val:=process32next(h,processstruc);
end;
end;