Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function ends a process and all of its threads.
Syntax
VOID ExitProcess( UINT uExitCode ); |
Parameters
- uExitCode
-
[in] Specifies the exit code for the process and for all threads that are terminated as a result of this call.
To retrieve the process's exit value, use the GetExitCodeProcessfunction.
To retrieve a thread's exit value, use the GetExitCodeThreadfunction.
Return Value
None.
Remarks
This function is the preferred method of ending a process because it provides a clean process shutdown. This includes calling the entry-point function of all attached DLLs with a value indicating that the process is detaching from the DLL.
After all attached DLLs have executed a process termination value, this function terminates the current process.
The following actions are caused by terminating a process:
- All object handles that were opened by the process are closed.
- All threads in the process terminate their execution.
- The state of the process object becomes signaled, satisfying
threads waiting for the process to terminate.
- The states of all threads of the process become signaled,
satisfying threads 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 necessarily remove the process object from the OS. A process object is deleted when the last handle to the process is closed.
A process that is started as a result of a call by CreateProcessis run serially with the ExitProcess, ExitThread, and CreateThreadfunctions. Within the parent process, only one of these events can happen in an address space at a time.
The following list shows the restrictions during the process:
- During process startup and DLL initialization routines, new
threads can be created, but they do not begin execution until DLL
initialization is done for the process.
- In a process, only one thread at a time can be in a DLL
initialization or detach routine.
-
ExitProcessdoes not return to processes in the DLL
initialization or detach routine.
Requirements
Header | windows.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |