给你一个关闭进程的函数
//杀死进程
function TForm1.Kill_Task(ExeFileName: string):integer;
const
PROCESS_TERMINATE=$0001; //进程的PROCESS_TERMINATE访问权限
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result:= 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //获取系统所有进程快照
FProcessEntry32.dwSize := Sizeof(FProcessEntry32); //调用Process32First前用Sizeof(FProcessEntry32)填充FProcessEntry32.dwSize
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32); //获取快照中第一个进程信息并保存到FProcessEntry32结构体中
while integer(ContinueLoop) <> 0 do //循环枚举快照中所有进程信息
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))=UpperCase(ExeFileName))
or (UpperCase(FProcessEntry32.szExeFile)=UpperCase(ExeFileName))) then //找到要中止的进程名
Result := Integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),FProcessEntry32.th32ProcessID), 0)); //中止进程
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32); //查找下一个符合条件进程
end;
end;