求助:结束进程不能访问网络的问题??? ( 积分: 50 )

  • 主题发起人 主题发起人 rein
  • 开始时间 开始时间
R

rein

Unregistered / Unconfirmed
GUEST, unregistred user!
从网上COPY了这段代码..它能杀死指定的进程..但运行后我就不能访问网络了..而且它的进程强制结束也结束不了...不知是怎么回事???<br>uses<br><br>Tlhelp32;<br><br>function KillTask(ExeFileName: string): Integer;<br><br>const<br><br>PROCESS_TERMINATE = $0001;<br><br>var<br><br>ContinueLoop: BOOL;<br><br>FSnapshotHandle: THandle;<br><br>FProcessEntry32: TProcessEntry32;<br><br>begin<br><br>Result := 0;<br><br>FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br><br>FProcessEntry32.dwSize := SizeOf(FProcessEntry32);<br><br>ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);<br><br>while Integer(ContinueLoop) &lt;&gt; 0 do<br><br>begin<br><br>if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =<br><br>UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =<br><br>UpperCase(ExeFileName))) then<br><br>Result := Integer(TerminateProcess(<br><br>OpenProcess(PROCESS_TERMINATE,<br><br>BOOL(0),<br><br>FProcessEntry32.th32ProcessID),<br><br>0));<br><br>ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);<br><br>end;<br><br>CloseHandle(FSnapshotHandle);<br><br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br>begin<br><br>KillTask('PFW.exe');<br><br>end;
 
从网上COPY了这段代码..它能杀死指定的进程..但运行后我就不能访问网络了..而且它的进程强制结束也结束不了...不知是怎么回事???<br>uses<br><br>Tlhelp32;<br><br>function KillTask(ExeFileName: string): Integer;<br><br>const<br><br>PROCESS_TERMINATE = $0001;<br><br>var<br><br>ContinueLoop: BOOL;<br><br>FSnapshotHandle: THandle;<br><br>FProcessEntry32: TProcessEntry32;<br><br>begin<br><br>Result := 0;<br><br>FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br><br>FProcessEntry32.dwSize := SizeOf(FProcessEntry32);<br><br>ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);<br><br>while Integer(ContinueLoop) &lt;&gt; 0 do<br><br>begin<br><br>if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =<br><br>UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =<br><br>UpperCase(ExeFileName))) then<br><br>Result := Integer(TerminateProcess(<br><br>OpenProcess(PROCESS_TERMINATE,<br><br>BOOL(0),<br><br>FProcessEntry32.th32ProcessID),<br><br>0));<br><br>ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);<br><br>end;<br><br>CloseHandle(FSnapshotHandle);<br><br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br><br>begin<br><br>KillTask('PFW.exe');<br><br>end;
 
你不能访问网络可能是应为你强制关闭了网络防火墙所致,因为现在的安全软件一般都有自我保护功能
 
后退
顶部