能不能直接在自己的进程里 终止其他进程里的线程??

解决方案 »

  1.   

    TerminateProcess
    The TerminateProcess function terminates the specified process and all of its threads. BOOL TerminateProcess(
      HANDLE hProcess, // handle to the process
      UINT uExitCode   // exit code for the process
    );
     
    Parameters
    hProcess 
    Handle to the process to terminate. 
    Windows NT: The handle must have PROCESS_TERMINATE access. uExitCode 
    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. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError. Res
    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. 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. Terminating a process causes the following: All of the object handles opened by the process are closed. 
    All of the threads in the process terminate their execution. 
    The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. 
    The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate. 
    The termination status of the process changes from STILL_ACTIVE to the exit value of the process. 
    Terminating a process does not cause child processes to be terminated. 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. Windows CE: Windows CE does not support exit codes for processes, so the uExitCode parameter is ignored.QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winbase.h.
      Import Library: Use kernel32.lib.See Also
    Processes and Threads Overview, Process and Thread Functions, ExitProcess, OpenProcess, GetExitCodeProcess, GetExitCodeThread