网站首页  词典首页

请输入您要查询的函数:

 

术语 initiatesystemshutdownex
释义 InitiateSystemShutdownEx
语法:
C++
BOOL WINAPI InitiateSystemShutdownEx(
__in_opt LPTSTR lpMachineName,
__in_opt LPTSTR lpMessage,
__in DWORD dwTimeout,
__in BOOL bForceAppsClosed,
__in BOOL bRebootAfterShutdown,
__in DWORD dwReason
);
InitiateSystemShutdownEx函数
启动关机和可选重新启动指定的计算机,并选择性地记录了关机原因。
参数
lpMachineName [中,可选]
计算机的网络名称被关闭。如果lpMachineName为NULL或空字符串,该函数关闭本地计算机。
lpMessage [中,可选]
该消息将显示在关机对话框中。此参数可以为NULL,如果没有消息是必需的。
Windows Server 2003和Windows XP中:此字符串也存储在一个事件日志项发表评论。
服务器2003和Windows XP SP1的:该字符串被限制为3072 TCHARs视窗。
dwTimeout [in]
的时间关机对话框中应显示的长度,以秒计。虽然此对话框显示时,可以停止关机的AbortSystemShutdown功能。
如果dwTimeout不为零,InitiateSystemShutdownEx上显示一个对话框中指定的计算机。该对话框显示谁的用户调用该函数的名称,显示了lpMessage参数指定的消息,并提示用户注销。该对话框声创建时和其它窗口上方仍然在系统中。该对话框可以移动,但不是封闭的。计时器的倒计时关机前的剩余时间。
如果dwTimeout为零,在计算机关机,而不显示对话框,并关闭不能由AbortSystemShutdown停止。
Windows Server 2003和Windows XP的SP1的:超时值仅限于MAX_SHUTDOWN_TIMEOUT秒。
Windows Server 2003和SP1的Windows XP:如果计算机是关闭终端服务的服务器,系统会显示一个对话框,所有本地和远程用户警告他们说,已经开始关闭。该对话框包括谁请关机,显示消息(见lpMessage),以及有多少时间,直到服务器关闭。
bForceAppsClosed [in]
如果这个参数为真,与未保存的更改,申请被强行关闭。如果此参数为FALSE,系统会显示一个对话框,指示用户关闭应用程序。
bRebootAfterShutdown [in]
如果此参数为TRUE,计算机重新启动后立即关闭。如果此参数为FALSE,系统所有缓存刷新到磁盘,安全地关闭系统的权力。
dwReason [in]
为启动关机原因。此参数必须是系统关闭原因代码之一。
如果此参数为0,则默认为未定义关闭被认为是“没有这个原因的标题可以找到记录”。默认情况下,它也是一个意外关机。根据系统如何配置,一个意外关机触发了一个文件,包含系统状态信息,它可以延迟关机创造。因此,不要使用此参数为零。
Windows XP/2000操作系统:系统状态信息不保存在一个计划外的系统关机。前面的文字并不适用。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
关闭本地计算机,调用线程必须有SE_SHUTDOWN_NAME特权。关闭远程计算机,调用线程必须在远程计算机上SE_REMOTE_SHUTDOWN_NAME特权。默认情况下,用户可以使他们对所登录到计算机SE_SHUTDOWN_NAME特权,管理员可以启用远程计算机上的SE_REMOTE_SHUTDOWN_NAME特权。有关更多信息,请运行特权。
失败的常见原因包括一个无效或无法访问的计算机名或00511。 ERROR_SHUTDOWN_IN_PROGRESS错误则返回关机已在指定的计算机上的进展。该错误ERROR_NOT_READY可以返回的快速用户切换功能,但没有用户登录。
一个非零返回值并不意味着被注销或将取得成功。关机是一个异步的过程,它可以发生后不久又回到了API调用,或根本没有。即使超时值为零,关机仍然可以胎死腹中的应用,服务,甚至系统。非零返回值表示的权利和参数验证成功,该系统接受了关闭的要求。
当此函数被调用,调用方必须指定与储存的变更申请是否应该强行关闭。如果调用方选择不强行关闭应用程序,并与未保存的更改应用程序运行的控制台会话,关机将继续进行,直到用户到控制台会话中止关闭,保存更改,关闭应用程序,或强制程序关闭。在此期间,关闭可能只由控制台用户,另有关机不得提出终止期限。
请注意,调用与设置为TRUE bForceAppsClosed参数值此功能可避免这种情况。请记住,这样做可能会导致数据丢失。
Windows Server 2003和Windows XP:如果计算机被锁定和bForceAppsClosed参数是FALSE,则最后一个错误代码是ERROR_MACHINE_LOCKED。如果系统没有准备好处理请求,最后一个错误代码是ERROR_NOT_READY。应用程序应该等待一会儿,然后重试通话。例如,该系统可没准备启动关闭,并返回ERROR_NOT_READY,关机的要求,同时用户试图登录到该系统来。在这种情况下,应用程序应待一会儿,然后重试通话。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinreg.h(头文件:winuser.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesInitiateSystemShutdownExW(Unicode)和InitiateSystemShutdownExA(ANSI)的
参见
关机
系统关机函数
AbortSystemShutdown
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==InitiateSystemShutdownEx Function
Initiates a shutdown and optional restart of the specified computer, and optionally records the reason for the shutdown.
Syntax
C++
BOOL WINAPI InitiateSystemShutdownEx(
__in_opt LPTSTR lpMachineName,
__in_opt LPTSTR lpMessage,
__in DWORD dwTimeout,
__in BOOL bForceAppsClosed,
__in BOOL bRebootAfterShutdown,
__in DWORD dwReason
);
Parameters
lpMachineName [in, optional]
The network name of the computer to be shut down. If lpMachineName is NULL or an empty string, the function shuts down the local computer.
lpMessage [in, optional]
The message to be displayed in the shutdown dialog box. This parameter can be NULL if no message is required.
Windows Server 2003 and Windows XP: This string is also stored as a comment in the event log entry.
Windows Server 2003 and Windows XP with SP1: The string is limited to 3072 TCHARs.
dwTimeout [in]
The length of time that the shutdown dialog box should be displayed, in seconds. While this dialog box is displayed, shutdown can be stopped by the AbortSystemShutdown function.
If dwTimeout is not zero, InitiateSystemShutdownEx displays a dialog box on the specified computer. The dialog box displays the name of the user who called the function, displays the message specified by the lpMessage parameter, and prompts the user to log off. The dialog box beeps when it is created and remains on top of other windows in the system. The dialog box can be moved but not closed. A timer counts down the remaining time before shutdown.
If dwTimeout is zero, the computer shuts down without displaying the dialog box, and the shutdown cannot be stopped by AbortSystemShutdown.
Windows Server 2003 and Windows XP with SP1: The time-out value is limited to MAX_SHUTDOWN_TIMEOUT seconds.
Windows Server 2003 and Windows XP with SP1: If the computer to be shut down is a Terminal Services server, the system displays a dialog box to all local and remote users warning them that shutdown has been initiated. The dialog box includes who requested the shutdown, the display message (see lpMessage), and how much time there is until the server is shut down.
bForceAppsClosed [in]
If this parameter is TRUE, applications with unsaved changes are to be forcibly closed. If this parameter is FALSE, the system displays a dialog box instructing the user to close the applications.
bRebootAfterShutdown [in]
If this parameter is TRUE, the computer is to restart immediately after shutting down. If this parameter is FALSE, the system flushes all caches to disk and safely powers down the system.
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 default 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 XP/2000: System state information is not saved during an unplanned system shutdown. The preceding text does not apply.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
To shut down the local computer, the calling thread must have the SE_SHUTDOWN_NAME privilege. To shut down a remote computer, the calling thread must have the SE_REMOTE_SHUTDOWN_NAME privilege on the remote computer. By default, users can enable the SE_SHUTDOWN_NAME privilege on the computer they are logged onto, and administrators can enable the SE_REMOTE_SHUTDOWN_NAME privilege on remote computers. For more information, see Running with Special Privileges .
Common reasons for failure include an invalid or inaccessible computer name or insufficient privilege. The error ERROR_SHUTDOWN_IN_PROGRESS is returned if a shutdown is already in progress on the specified computer. The error ERROR_NOT_READY can be returned if fast-user switching is enabled but no user is logged on.
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.
Note that calling this function with the value of the bForceAppsClosed parameter set to TRUE avoids this situation. Remember that doing this may result in loss of data.
Windows Server 2003 and Windows XP: If the computer is locked and the bForceAppsClosed parameter is FALSE, the last error code is ERROR_MACHINE_LOCKED. If the system is not ready to handle the request, the last error code is ERROR_NOT_READY. The application should wait a short while and retry the call. For example, the system can be unready to initiate a shutdown, and return ERROR_NOT_READY, if the shutdown request comes at the same time a user tries to log onto the system. In this case, the application should wait a short while and retry the call.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinreg.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesInitiateSystemShutdownExW (Unicode) and InitiateSystemShutdownExA (ANSI)
See Also
Shutting Down
System Shutdown Functions
AbortSystemShutdown
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa376874(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 13:25:56