用DEBUG_PROCESS标志创建的进程,如何终止(100分)

  • 主题发起人 主题发起人 ioi2000
  • 开始时间 开始时间
I

ioi2000

Unregistered / Unconfirmed
GUEST, unregistred user!
我用createprocess创建的debug进程不知道如何将他终止掉
 
function KillTask(ExeFileName: string): integer; &nbsp;//杀死进程的函数,来对付防火墙进程。<br>const<br>&nbsp; PROCESS_TERMINATE=$0001; &nbsp;//进程的PROCESS_TERMINATE访问权限<br>var<br>&nbsp; ContinueLoop: BOOL;<br>&nbsp; FSnapshotHandle: THandle;<br>&nbsp; FProcessEntry32: TProcessEntry32;<br>begin<br>&nbsp; result:= 0;<br>&nbsp; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br>&nbsp; //获取系统所有进程快照<br>&nbsp; FProcessEntry32.dwSize := Sizeof(FProcessEntry32);<br>&nbsp; //调用Process32First前用Sizeof(FProcessEntry32)填充FProcessEntry32.dwSize<br>&nbsp; ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);<br>&nbsp; //获取快照中第一个进程信息并保存到FProcessEntry32结构体中<br>&nbsp; while integer(ContinueLoop) &lt;&gt; 0 do<br>&nbsp; //循环枚举快照中所有进程信息<br>&nbsp; begin<br>&nbsp; &nbsp; if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile))=UpperCase(ExeFileName))<br>&nbsp; &nbsp; &nbsp; &nbsp; or (UpperCase(FProcessEntry32.szExeFile)=UpperCase(ExeFileName))) then<br>&nbsp; &nbsp; //找到要中止的进程名<br>&nbsp; &nbsp; &nbsp; &nbsp;Result := Integer(TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FProcessEntry32.th32ProcessID), 0));<br>&nbsp; &nbsp; &nbsp;//中止进程<br>&nbsp; &nbsp; &nbsp; &nbsp;ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);<br>&nbsp; &nbsp; &nbsp;//查找下一个符合条件进程<br>&nbsp; end;<br>end;
 
你也是用TerminateProcess终止进程,我之前也是啊,但根本就是就不行的
 
后退
顶部