用此函数,是我自家产的:<br>function KillTask(ExeFileName: string): integer;<br>const<br> PROCESS_TERMINATE=$0001;<br>var<br> ContinueLoop: BOOL;<br> FSnapshotHandle: THandle;<br> FProcessEntry32: TProcessEntry32;<br>begin<br> result := 0;<br> FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br> FProcessEntry32.dwSize := Sizeof(FProcessEntry32);<br> ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);<br> while integer(ContinueLoop) <> 0 do begin<br> if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =UpperCase(ExeFileName))<br> or (UpperCase(FProcessEntry32.szExeFile) =UpperCase(ExeFileName))) then<br> Result := Integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE,BOOL(0),FProcessEntry32.th32ProcessID),0));<br> ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);<br> end;<br> CloseHandle(FSnapshotHandle);<br>end;