VOID ExitProcess(fuExitCode) | |||||
UINT fuExitCode; | /* exit code for all threads | */ |
The ExitProcess function ends a process and all its threads.
fuExitCode
Specifies the exit code for each thread in the process.
This function does not return a value.
The ExitProcess function is the preferred method of ending a application. This function provides a clean application shutdown. This includes calling all attached DLLs at their instance termination entrypoint. If an application terminates by any other method, the DLLs that the process is attached to will not be notified of the process termination.
After notifying all DLLs of the process termination, this function terminates the current process.
ExitProcess, ExitThread, CreateThread, and a process that is starting (as the result of a CreateProcess call) are serialized between each other within a process. Only one of these events can happen in an address space at a time. This means that:
During process startup and DLL initialization routines, new threads may be created, but they will not begin execution until DLL initialization is done for the process.
Only one thread in a process may be in a DLL initialization or detach routine at a time.
ExitProcess will block until no threads are in their DLL initialization or detach routines.
CreateProcess, CreateThread, ExitProcess, ExitThread, OpenProcess TerminateProcess