Terminating a Process

< BACK  NEXT >
[oR]

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.


< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net