网站首页  词典首页

请输入您要查询的函数:

 

术语 exitwindowsex
释义 ExitWindowsEx
语法:
C++
BOOL WINAPI ExitWindowsEx(
__in UINT uFlags,
__in DWORD dwReason
);
ExitWindowsEx函数
关闭交互式用户日志,关闭系统,或者关闭并重新启动系统。它发送WM_QUERYENDSESSION消息给所有的应用程序,以确定是否可以终止。
参数
uFlags [in]
关闭类型。此参数必须包括下列值之一。
ValueMeaning
EWX_LOGOFF
0Shuts了所有进程的进程调用ExitWindowsEx函数登录会话中运行。然后注销用户。
这个标志只能用于在交互用户的登录会话中运行的进程。
EWX_POWEROFF
0x00000008Shuts关闭系统,并关闭电源。该系统必须支持关闭电源功能。
调用进程必须有SE_SHUTDOWN_NAME特权。有关详细信息,请参阅下面的备注部分。
EWX_REBOOT
0x00000002Shuts关闭系统,然后重新启动系统。
调用进程必须有SE_SHUTDOWN_NAME特权。有关详细信息,请参阅下面的备注部分。
EWX_RESTARTAPPS
0x00000040Shuts关闭系统,然后重新启动它,以及任何已申请重新注册使用RegisterApplicationRestart功能。这些应用程序收到的设置为ENDSESSION_CLOSEAPP价值lparam的WM_QUERYENDSESSION消息。有关更多信息,请参阅申请的指引。
EWX_SHUTDOWN
0x00000001Shuts关闭系统的问题上,可以安全地关闭电源。所有文件缓冲区已经刷新到磁盘上,所有正在运行的进程已经停止。
调用进程必须有SE_SHUTDOWN_NAME特权。有关详细信息,请参阅下面的备注部分。
指定此标志将不会关闭电源,即使系统支持关闭电源功能。您必须指定EWX_POWEROFF做到这一点。
带有SP1的Windows XP:如果系统支持断电功能,指定此标志关闭电源。
此参数可以选择包括下列值之一。
ValueMeaning
EWX_FORCE
0x00000004This标志,如果没有启用终端服务的影响。否则,系统不发送WM_QUERYENDSESSION消息。这可能会导致应用程序丢失数据。因此,您应该只在紧急情况下使用此标志。
EWX_FORCEIFHUNG
0x00000010Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message within the timeout interval.有关详细信息,请参见备注。
dwReason [in]
为启动关机原因。此参数必须是系统关闭原因代码之一。
如果此参数为0,SHTDN_REASON_FLAG_PLANNED原因代码将不会被设置,因此,默认操作是一个未定义的关闭被认为是“没有这个原因的标题可以找到记录”。默认情况下,它也是一个意外关机。根据系统如何配置,一个意外关机触发了一个文件,包含系统状态信息,它可以延迟关机创造。因此,不要使用此参数为零。
Windows 2000中:此参数被忽略。
返回值
如果函数成功,返回值为非零。因为函数执行异步,非零返回值表示已经开始关闭。它没有说明是否会成功关机。很可能,该系统,用户,或其他应用程序将中止关闭。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
ExitWindowsEx函数返回后尽快已开始在关机过程。关闭或注销,然后异步收益。该函数的目的是停止在调用方的登录会话的所有进程。因此,如果您不是交互式用户,函数可以没有实际成功关闭计算机。如果您不是交互式用户,使用InitiateSystemShutdown或InitiateSystemShutdownEx函数。
一个非零返回值并不意味着被注销或将取得成功。关机是一个异步的过程,它可以发生后不久又回到了API调用,或根本没有。即使超时值为零,关机仍然可以胎死腹中的应用,服务,甚至系统。非零返回值表示的权利和参数验证成功,该系统接受了关闭的要求。
当此函数被调用,调用方必须指定与储存的变更申请是否应该强行关闭。如果调用方选择不强行关闭应用程序,并与未保存的更改应用程序运行的控制台会话,关机将继续进行,直到用户到控制台会话中止关闭,保存更改,关闭应用程序,或强制程序关闭。在此期间,关机不得终止除非由控制台用户,另有关机可能不会启动。
调用同uFlags值这个功能的参数设置为EWX_FORCE避免这种情况。请记住,这样做可能会导致数据丢失。
要设置一个应用程序关机的权利优先于系统中的其他应用程序,使用SetProcessShutdownParameters功能。
在关机或登录关操作,允许运行应用程序的时间具体数额回应关机请求。如果这个时间届满之前,所有的应用程序已经停止,系统会显示用户界面,允许用户强行关闭系统或取消关机要求。如果EWX_FORCE指定值,系统运行的应用程序部队停止在时间到期时。
如果EWX_FORCEIFHUNG指定值,系统的力量挂应用程序关闭,不显示该对话框。
控制台程序收到一个单独的通知消息,CTRL_SHUTDOWN_EVENT或CTRL_LOGOFF_EVENT,随着形势的需要。一个控制台工艺路线的HandlerRoutine这些功能的信息。调用ExitWindowsEx发送这些异步通知消息,因此,应用程序不能假设控制台通知邮件已被处理,以调用ExitWindowsEx时调用返回。
关闭或重新启动系统,调用进程必须使用AdjustTokenPrivileges函数使SE_SHUTDOWN_NAME特权。有关更多信息,请运行特权。
实例
有关示例,请参见如何关闭系统。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinuser.h(头文件:winuser.h)
LibraryUser32.lib
DLLUser32.dll
参见
注销
关机
系统关机函数
AdjustTokenPrivileges
HandlerRoutine
SetProcessShutdownParameters
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==ExitWindowsEx Function
Logs off the interactive user, shuts down the system, or shuts down and restarts the system. It sends the WM_QUERYENDSESSION message to all applications to determine if they can be terminated.
Syntax
C++
BOOL WINAPI ExitWindowsEx(
__in UINT uFlags,
__in DWORD dwReason
);
Parameters
uFlags [in]
The shutdown type. This parameter must include one of the following values.
ValueMeaning
EWX_LOGOFF
0Shuts down all processes running in the logon session of the process that called the ExitWindowsEx 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
0x00000008Shuts 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
0x00000002Shuts 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
0x00000040Shuts down the system and then restarts it, as well as any applications that have been registered for restart using the RegisterApplicationRestart function. These application receive the WM_QUERYENDSESSION message with lParam set to the ENDSESSION_CLOSEAPP value. For more information, see Guidelines for Applications .
EWX_SHUTDOWN
0x00000001Shuts 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 with SP1: If the system supports the power-off feature, specifying this flag turns off the power.

This parameter can optionally include one of the following values.
ValueMeaning
EWX_FORCE
0x00000004This flag has no effect if terminal services is enabled. Otherwise, the system does not send the WM_QUERYENDSESSION message. This can cause applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_FORCEIFHUNG
0x00000010Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message within the timeout interval. For more information, see the Remarks.

dwReason [in]
The reason for initiating the shutdown. This parameter must be one of the 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.
Windows 2000: This parameter is ignored.
Return Value
If the function succeeds, the return value is nonzero. Because the function executes asynchronously, a nonzero return value indicates that the shutdown has been initiated. It does not indicate whether the shutdown will succeed. It is possible that the system, the user, or another application will abort the shutdown.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
The ExitWindowsEx function returns as soon as it has initiated the shutdown process. The shutdown or logoff then proceeds asynchronously. The function is designed to stop all processes in the caller's logon session. Therefore, if you are not the interactive user, the function can succeed without actually shutting down the computer. If you are not the interactive user, use the InitiateSystemShutdown or InitiateSystemShutdownEx function.
A non-zero return value does not mean the logoff was or will be successful. The shutdown is an asynchronous process, and it can occur long after the API call has returned, or not at all. Even if the timeout value is zero, the shutdown can still be aborted by applications, services, or even the system. The non-zero return value indicates that the validation of the rights and parameters was successful and that the system accepted the shutdown request.
When this function is called, the caller must specify whether or not applications with unsaved changes should be forcibly closed. If the caller chooses not to force these applications to close and an application with unsaved changes is running on the console session, the shutdown will remain in progress until the user logged into the console session aborts the shutdown, saves changes, closes the application, or forces the application to close. During this period, the shutdown may not be aborted except by the console user, and another shutdown may not be initiated.
Calling this function with the value of the uFlags parameter set to EWX_FORCE avoids this situation. Remember that doing this may result in loss of data.
To set a shutdown priority for an application relative to other applications in the system, use the SetProcessShutdownParameters function.
During a shutdown or log-off operation, running applications are allowed a specific amount of time to respond to the shutdown request. If this time expires before all applications have stopped, the system displays a user interface that allows the user to forcibly shut down the system or to cancel the shutdown request. If the EWX_FORCE value is specified, the system forces running applications to stop when the time expires.
If the EWX_FORCEIFHUNG value is specified, the system forces hung applications to close and does not display the dialog box.
Console processes receive a separate notification message, CTRL_SHUTDOWN_EVENT or CTRL_LOGOFF_EVENT, as the situation warrants. A console process routes these messages to its HandlerRoutine function. ExitWindowsEx sends these notification messages asynchronously; thus, an application cannot assume that the console notification messages have been handled when a call to ExitWindowsEx returns.
To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information, see Running with Special Privileges .
Examples
For an example, see How to Shut Down the System .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll
See Also
Logging Off
Shutting Down
System Shutdown Functions
AdjustTokenPrivileges
HandlerRoutine
SetProcessShutdownParameters
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa376868(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:22:30