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 shuts down the system.
Syntax
BOOL ExitWindowsEx( UINT uFlags, DWORD dwReserved ); |
Parameters
- uFlags
-
[in] Specifies the type of shutdown, with options for immediate or deferred reboot, or a prompted reboot. This parameter can be one or a combination of the following values:
Value Description EWX_POWEROFF
Shuts down the system and turns off the power.
This flag is not supported on Windows Mobile Professional or Windows Mobile Classic.
EWX_REBOOT
Shuts down the system and reboots the device.
EWX_DEFER
EWX_DEFER must be bitwise ORed with EWX_REBOOT and/or EWX_PROMPT. If EWX_DEFER is passed alone, ExitWindowsExfails.
Specifying EWX_DEFER ORed with EWX_REBOOT defers the reboot to a later time when no reboot deferral sessions are active. (A reboot deferral session is an internal system state during which reboots are not allowed.) If no reboot deferral sessions are active when you call ExitWindowsEx, a reboot is initiated immediately and completed asynchronously. Using this flag modifier allows callers not to worry about whether it is safe to call this function at any point in their code execution.
Specifying EWX_DEFER bitwise ORed with EWX_PROMPT and EWX_REBOOT defers the reboot to a later time when no reboot deferral sessions are active, and prompts the user when it is time to initiate a reboot.
EWX_PROMPT
EWX_PROMPT must be bitwise ORed with EWX_REBOOT. EWX_PROMPT can also be bitwise ORed with EWX_DEFER; see EWX_DEFER for a description of the behavior. If EWX_PROMPT is passed alone, ExitWindowsExfails.
Specifying EWX_PROMPT with EWX_REBOOT causes the system to prompt the user for permission to reboot. The user can choose to reboot either immediately or later. This function initiates a reboot only if the user agrees to an immediate reboot. If the user chooses to reboot later, the notification reappears after a pre-set amount of time, and continues to reappear at regular intervals until the user chooses to reboot. The use of EWX_PROMPT helps applications satisfy the e-call requirement by transferring control of system reboots to the user.
- dwReserved
-
[in] Reserved; this parameter is ignored.
Return Value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
Remarks
This function returns as soon as it has initiated the reboot/shutdown, and the reboot/shutdown then proceeds asynchronously. Because the function executes asynchronously, a nonzero return value indicates that the shutdown has been initiated. A nonzero return value does not, however, guarantee that the shutdown will succeed, because the system, the user, or another application can abort the shutdown.
If the function fails, you can obtain extended error information by calling GetLastError.
The flags EWX_DEFERand EWX_PROMPTallow applications to observe reboot deferral sessions (defer) or require user permission for rebooting (by prompting the user). A reboot deferral session is an internal system state during which reboots are not allowed. If an application calls ExitWindowsExwithout passing EWX_DEFERwhile a reboot deferral session is active, it could produce unpredictable results.
EWX_PROMPTand EWX_DEFERare only valid when ORed with EWX_REBOOT. They have no effect when bitwise ORed with EWX_POWEROFFor when used without the reboot or shutdown flags.
Examples
ExitWindowsEx(EWX_REBOOT | EWX_DEFER, 0);
This call causes the reboot to be deferred to a later time, based on currently active reboot deferral sessions.
ExitWindowsEx(EWX_REBOOT | EWX_PROMPT, 0);
This call causes the system to prompt the user with a notification requesting permission to reboot. If the user agrees, a reboot is initiated immediately, regardless of whether a deferral session is currently active or not. If the user chooses to reboot later, the notification keeps reappearing after a pre-set amount of time, until the user chooses to reboot.
ExitWindowsEx(EWX_REBOOT | EWX_DEFER | EWX_PROMPT, 0);
This call causes the reboot to be deferred to a later time, based on currently active reboot deferral sessions. Then, when it is time to initiate a reboot, the system prompts the user with a notification requesting permission to reboot.
Requirements
Header | aygshell.h |
Windows Mobile | Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later |