Function to kill a process with the given name:
uses jwatlhelp32, jwawindows;
procedure KillProcess(name: String);
var h:tHandle;
pe:tProcessEntry32;
sPrcName:string;
begin
h:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
try
pe.dwSize:=SizeOf(pe);
if Process32First(h,pe) then begin
while Process32Next(h,pe) do
begin
sPrcName:=pe.szExeFile;
if pos(LowerCase(name),LowerCase(sPrcName))>0 then
begin
TerminateProcess(OpenProcess(Process_Terminate, False, pe.th32ProcessID), 0);
end;
end;
end
else RaiseLastOSError;
finally
end;
end;