在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
procedure KillProcess(ExeName: string); const PROCESS_TERMINATE = $0001; //进程的PROCESS_TERMINATE访问权限 var ContinueLoop: Boolean; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin //获取系统所有进程快照 FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //调用Process32First前用Sizeof(FProcessEntry32)填充FProcessEntry32.dwSize FProcessEntry32.dwSize := Sizeof(FProcessEntry32); //获取快照中第一个进程信息并保存到FProcessEntry32结构体中 ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32); while integer(ContinueLoop) <> 0 do //循环枚举快照中所有进程信息 begin //找到要中止的进程名 if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeName))) then TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),FProcessEntry32.th32ProcessID), 0); //中止进程 ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32); //查找下一个符合条件进程 end; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论