需要引用单元 Tlhelp32
function KillTask(ExeFileName: string): integer; //杀进程函数 const PROCESS_TERMINATE = $0001; var ContinueLoop: BOOL; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //取得系统快照 FProcessEntry32.dwSize := Sizeof(FProcessEntry32); //循环例举,如果到达最后,则退出loop ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32); while integer(ContinueLoop) <> 0 do begin //取得进程名,大写后好作比较 if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))= UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then //调用terminateprocess结束符合的进程项 Result := Integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32); end; end; //ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32); //这一句是从进程链中,取出一个到FProcessEntry32结构中,然后 //在这个结构中取得进程名。至于FProcessEntry32,你用按下ctrl同时在这个上面鼠标点下,可以看到它的详细定义。