现在的位置: 首页 > 综合 > 正文

ExitWindowsEx

2013年04月26日 ⁄ 综合 ⁄ 共 2403字 ⁄ 字号 评论关闭

 

 

ExitWindowsEx Function

注销交互的使用者,关闭系统,或关机重启系统。它发送 WM_QUERYENDSESSION消息给所有的应用程序

BOOL WINAPI ExitWindowsEx(
  __in          UINT uFlags,
  __in          DWORD dwReason
);

 

Parameters

uFlags

关闭的类型,如下:

 

EWX_LOGOFF
0

Shuts down all processes running in the logon session of the process that called theExitWindowsEx function. Then it logs the user off.

This flag can be used only by processes running in an interactive user's logon session.

EWX_POWEROFF
0x00000008

Shuts down the system and turns off the power. The system must support the power-off feature.

The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.

EWX_REBOOT
0x00000002

Shuts down the system and then restarts the system.

The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.

EWX_RESTARTAPPS
0x00000040

Shuts down the system and then restarts it, as well as any applications that have been registered for restart using theRegisterApplicationRestart function. These application receive theWM_QUERYENDSESSION message with
lParam set to the ENDSESSION_CLOSEAPP value. For more information, see Guidelines for Applications.

EWX_SHUTDOWN
0x00000001

Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped.

The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.

Specifying this flag will not turn off the power even if the system supports the power-off feature. You must specify EWX_POWEROFF to do this.

Windows XP SP1:  If the system supports the power-off feature, specifying this flag turns off the power.

dwReason

初始化系统的原因。see  system shutdown reason codes.

If this parameter is zero, the SHTDN_REASON_FLAG_PLANNED reason code will not be set and therefore the default action is an undefined shutdown that is logged as "No title for this reason could be found". By default, it is also an unplanned shutdown. Depending
on how the system is configured, an unplanned shutdown triggers the creation of a file that contains the system state information, which can delay shutdown. Therefore, do not use zero for this parameter.

 

SHTDN_REASON_MAJOR_APPLICATION
0x00040000

Application issue.

SHTDN_REASON_MAJOR_HARDWARE
0x00010000

Hardware issue.

SHTDN_REASON_MAJOR_LEGACY_API
0x00070000

The InitiateSystemShutdown function was used instead ofInitiateSystemShutdownEx.

SHTDN_REASON_MAJOR_OPERATINGSYSTEM
0x00020000

Operating system issue.

SHTDN_REASON_MAJOR_OTHER
0x00000000

Other issue.

SHTDN_REASON_MAJOR_POWER
0x00060000

Power failure.

SHTDN_REASON_MAJOR_SOFTWARE
0x00030000

Software issue.

SHTDN_REASON_MAJOR_SYSTEM
0x00050000

System failure

抱歉!评论已关闭.