怎样才能关闭所有进程?(100分)

  • 主题发起人 主题发起人 sakura12
  • 开始时间 开始时间
S

sakura12

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样才能彻底关闭所有进程?[red][/red][:(]
 
循环使用terminateprocess()即可!
 
[red][/red][?]请问具体该怎么用?我是初级菜鸟,不是很懂的,能否详细点?谢谢指教!
 
关闭所有的程序:<br>procedure TForm1.ButtonKillAllClick(Sender: TObject);<br>var<br>&nbsp; &nbsp; pTask : PTaskEntry;<br>&nbsp; &nbsp; Task : Bool;<br>&nbsp; &nbsp; ThisTask: THANDLE;<br>begin<br>&nbsp; &nbsp; GetMem (pTask, SizeOf (TTaskEntry));<br>&nbsp; &nbsp; pTask^.dwSize := SizeOf (TTaskEntry);<br>&nbsp; &nbsp; Task := TaskFirst (pTask);<br>&nbsp; &nbsp; while Task do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if pTask^.hInst = hInstance then<br>&nbsp; &nbsp; &nbsp; &nbsp; ThisTask := pTask^.hTask<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; TerminateApp (pTask^.hTask, NO_UAE_BOX);<br>&nbsp; &nbsp; &nbsp; &nbsp; Task := TaskNext (pTask);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; TerminateApp (ThisTask, NO_UAE_BOX);<br>end;<br><br>这样应该够了吧<br>不用这么狠心关闭所有进程吧!<br>而且那样windows运行不下去的呵!
 
回 vine兄:<br>这段代码我在葵花宝典上看到过,但是我不知道为什么,老是不能编译,提示有错。我再试一试<br>你给我的这段代码,麻烦你能不能告诉我你自己编译过这段代码吗?谢谢你的帮助。<br><br>回 YB_unique兄:<br>循环使用terminateprocess()这个命令具体怎么用,能否详细告知,我很笨的,谢谢了。<br>
 
不可能关闭所有的进程的,有的进程是关闭不了的,<br>然后有的进程如果关闭,windows是无法响音的。<br>呵呵.<br><br>TerminateProcess<br>The TerminateProcess function terminates the specified process and all of its threads. <br><br>BOOL TerminateProcess(<br>&nbsp; HANDLE hProcess, // handle to the process<br>&nbsp; UINT uExitCode &nbsp; // exit code for the process<br>);<br>Parameters<br>hProcess <br>[in] Handle to the process to terminate. <br>Windows NT/2000/XP: The handle must have PROCESS_TERMINATE access. For more information, see Process Security and Access Rights. <br><br>uExitCode <br>[in] Specifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value. <br>Return Values<br>If the function succeeds, the return value is nonzero.<br><br>If the function fails, the return value is zero. To get extended error information, call GetLastError. <br><br>Remarks<br>The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess. <br><br>TerminateProcess causes all threads within a process to terminate, and causes a process to exit, but DLLs attached to the process are not notified that the process is terminating. <br><br>Terminating a process causes the following: <br><br>All of the object handles opened by the process are closed. <br>All of the threads in the process terminate their execution. <br>The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. <br>The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate. <br>The termination status of the process changes from STILL_ACTIVE to the exit value of the process. <br>Terminating a process does not cause child processes to be terminated. <br><br>Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. <br><br>Terminating a process does not generate notifications for WH_CBT hook procedures. <br><br>Requirements <br>&nbsp; Windows NT/2000/XP: Included in Windows NT 3.1 and later.<br>&nbsp; Windows 95/98/Me: Included in Windows 95 and later.<br>&nbsp; Header: Declared in Winbase.h; include Windows.h.<br>&nbsp; Library: Use Kernel32.lib.<br><br>See Also<br>Processes and Threads Overview, Process and Thread Functions, ExitProcess, OpenProcess, GetExitCodeProcess, GetExitCodeThread <br><br><br>
 
后退
顶部