Terminating a Process

There are rare occasions when you will need to terminate another process from your application. Calling TerminateProcess does this.

DWORD dwExitCode = 1;
if(TerminateProcess(hProcess, dwExitCode))
  cout ≪ _T("Process Terminated");

The function TerminateProcess is passed the handle of the process to terminate as the first parameter and a DWORD containing the exit code to use for the process. The process being terminated does not have the opportunity to set an exit code, so one must be provided.

You should avoid calling TerminateProcess, since DLLs being used by the process do not have DllMain called with the reason code DLL_PROCESS_ DETACH. Therefore, the DLLs cannot free resources they are using and resource or memory leaks can result.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.133.96