Terminating a Process

The most common way to terminate a process is to have it return from a WinMain function call. You can also terminate a process by having the primary thread of the process call the ExitThread function. A Windows CE process automatically terminates if its primary thread is terminated, even if there are other active threads in existence for the process. ExitThread returns the exit code of the process. You can determine the exit code of a process by calling the GetExitCodeProcess function. Specify the handle to the process, which you can obtain by calling the CreateProcess or OpenProcess function; the function returns the exit code. If the process is still running, the function returns the STILL_ACTIVE termination status.

There are also other, less common, ways of terminating a process:

Note A process immediately terminates if a related secondary thread generates an unhandled exception. This is a change in behavior from Windows CE version 2.10 or earlier.