全部源代码如下(无窗体结构,最后面有说明):
program Project1;
uses
Winprocs,SysUtils,Tlhelp32;//注意添加单元文件
function KillTask(ExeFileName:string):integer;//杀进程函数KillTask
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOLean;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result :=0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, 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,
BOO
守护进程-----杀死自己的进程再重新启动自己
最新推荐文章于 2022-08-11 10:13:32 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)