procedure Killpro(s: string);
var
lppe: tprocessentry32;
sshandle: thandle;
hh: hwnd;
found: boolean;
begin
sshandle := createtoolhelp32snapshot(TH32CS_SNAPPROCESS, 0);
lppe.dwSize := SizeOf(tprocessentry32);
found := process32first(sshandle, lppe);
while found do
begin
if (ansicomparetext(extractfilename(lppe.szExeFile) , s)=0) or
(ansicomparetext(lppe.szExeFile, s)=0) then
begin
hh := OpenProcess(PROCESS_ALL_ACCESS, true, lppe.th32ProcessID);
TerminateProcess(hh, 0);
end;
found := process32next(sshandle, lppe);
end;
CloseHandle(sshandle);
end;
//调用
Killpro('Explorer.Exe');