1个回答
展开全部
Function KillProcess(TheProcName:String):boolean;
var
isOK:Boolean;
ProcessHandle:Thandle;
ProcessStruct:TProcessEntry32;
Function KillProcessID(ProcessID:Cardinal):boolean;
var
H:THandle;
begin
H:=OpenProcess(Process_All_Access, true,ProcessID);
Result:=TerminateProcess(H,0);
end;
begin
ProcessHandle:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
processStruct.dwSize:=sizeof(ProcessStruct);
isOK:=process32first(ProcessHandle,ProcessStruct);
while isOK do
begin
if TheProcName=ProcessStruct.szExeFile then
begin
Result:=KillProcessID(ProcessStruct.th32ProcessID);
CloseHandle(ProcessHandle);
exit;
end;
isOK:=process32next(ProcessHandle,ProcessStruct);
end;
CloseHandle(ProcessHandle);
Result:=True;
end;
应该是你要的吧?
var
isOK:Boolean;
ProcessHandle:Thandle;
ProcessStruct:TProcessEntry32;
Function KillProcessID(ProcessID:Cardinal):boolean;
var
H:THandle;
begin
H:=OpenProcess(Process_All_Access, true,ProcessID);
Result:=TerminateProcess(H,0);
end;
begin
ProcessHandle:=createtoolhelp32snapshot(Th32cs_snapprocess,0);
processStruct.dwSize:=sizeof(ProcessStruct);
isOK:=process32first(ProcessHandle,ProcessStruct);
while isOK do
begin
if TheProcName=ProcessStruct.szExeFile then
begin
Result:=KillProcessID(ProcessStruct.th32ProcessID);
CloseHandle(ProcessHandle);
exit;
end;
isOK:=process32next(ProcessHandle,ProcessStruct);
end;
CloseHandle(ProcessHandle);
Result:=True;
end;
应该是你要的吧?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询