下面的代码通过!
uses ...,TLHelp32,...
procedure TForm1.Button1Click(Sender: TObject);
var
cLoop:boolean;
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
begin
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
cLoop:=Process32First(FSnapshotHandle,FProcessEntry32);
while integer(cLoop)<>0 do
begin
if FProcessEntry32.szExeFile='alg.exe' then
TerminateProcess(OpenProcess(PROCESS_TERMINATE,False,FProcessEntry32.th32ProcessID),$FFFFFFFF);
cLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
closehandle(FSnapshothandle);
end;