网站首页  词典首页

请输入您要查询的函数:

 

术语 initiateshutdown
释义 InitiateShutdown
语法:
C++
DWORD WINAPI InitiateShutdown(
__in_opt LPTSTR lpMachineName,
__in_opt LPTSTR lpMessage,
__in DWORD dwGracePeriod,
__in DWORD dwShutdownFlags,
__in DWORD dwReason
);
InitiateShutdown功能
启动关机并重新启动指定的计算机,并重新启动任何已注册的应用程序重新启动。
参数
lpMachineName [中,可选]
计算机的名称,被关闭。如果这个参数的值为NULL,则本地计算机关闭。
lpMessage [中,可选]
该消息将显示在交互式关机对话框。
dwGracePeriod [in]
在等待的秒数之前关闭计算机。如果这个参数的值是零,计算机立即关闭。此值被限制为MAX_SHUTDOWN_TIMEOUT。
如果该参数值大于零,dwShutdownFlags参数指定的国旗SHUTDOWN_GRACE_OVERRIDE,函数失败并返回错误代码ERROR_BAD_ARGUMENTS。
dwShutdownFlags [in]
一个或多个位标志指定的关机选项。下面的值定义。
ValueMeaning
SHUTDOWN_FORCE_OTHERS
0x00000001(0x1)所有会议都有力地注销。如果此标志未设置和用户以外的当前用户正在由lpMachineName参数指定的计算机登录,此函数失败的ERROR_SHUTDOWN_USERS_LOGGED_ON返回值。
SHUTDOWN_FORCE_SELF
0x00000002(0x2)指定原始会话注销有力。如果此标志没有设置,原始会话关闭交互,所以关机不能保证,即使该函数返回成功。
SHUTDOWN_GRACE_OVERRIDE
0x00000020(0x20)覆盖的宽限期,以便计算机立即关闭。
SHUTDOWN_INSTALL_UPDATES
0x00000040(0x40)电脑安装开始之前关闭任何更新。
SHUTDOWN_NOREBOOT
0x00000010(0x10)电脑关闭,但没有关机或重新启动。
SHUTDOWN_POWEROFF
0x00000008(0x8)计算机是关闭并关机。
SHUTDOWN_RESTART
0x00000004(0x4)计算机是关闭并重新启动。
SHUTDOWN_RESTARTAPPS
0x00000080(0x80)重新启动该系统使用具有EWX_RESTARTAPPS旗ExitWindowsEx函数。这重新启动任何应用程序已重新登记使用RegisterApplicationRestart功能。
dwReason [in]
为启动关机原因。此参数必须是系统关闭原因代码之一。如果此参数为0,则默认为未定义关闭被认为是“没有这个原因的标题可以找到记录”。默认情况下,它也是一个意外关机。根据系统如何配置,一个意外关机触发了一个文件,包含系统状态信息,它可以延迟关机创造。因此,不要使用此参数为零。
返回值
如果函数成功,它返回ERROR_SUCCESS。
如果函数失败,返回下列错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe调用没有所需的特权(SE_SHUTDOWN_PRIVILEGE或SE_REMOTE_SHUTDOWN_PRIVILEGE)执行此操作。
ERROR_BAD_NETPATHThe指定的电脑不存在或无法访问。
ERROR_INVALID_COMPUTERNAMEThe指定的计算机名称不是有效的计算机名称。
ERROR_INVALID_FUNCTIONThe指定的计算机不支持关机界面。
ERROR_INVALID_PARAMETERAn无效的参数设置通过。这包括下列组合。
在lpMachineName参数指定远程计算机,并且dwShutdownFlags参数不指定SHUTDOWN_FORCE_SELF。
该dwGracePeriod值大于零,dwShutdownFlags参数不指定SHUTDOWN_FORCE_SELF。
该dwGracePeriod值大于零,dwShutdownFlags参数指定SHUTDOWN_GRACE_OVERRIDE。
ERROR_SHUTDOWN_IN_PROGRESSA关机已经开始在指定的计算机。
ERROR_SHUTDOWN_IS_SCHEDULEDA指定的计算机关机已定,但没有启动。这一职能的成功,SHUTDOWN_GRACE_OVERRIDE必须设置标志。
ERROR_SHUTDOWN_USERS_LOGGED_ONOne或更多的用户比目前的其他用户登录指定的计算机,并SHUTDOWN_FORCE_OTHERS国旗还没有确定。
备注
关闭本地计算机,调用线程必须有SE_SHUTDOWN_NAME特权。关闭远程计算机,调用线程必须在远程计算机上SE_REMOTE_SHUTDOWN_NAME特权。默认情况下,用户可以使他们对所登录到计算机SE_SHUTDOWN_NAME特权,管理员可以启用远程计算机上的SE_REMOTE_SHUTDOWN_NAME特权。有关更多信息,请运行特权。
失败的常见原因包括一个无效或无法访问的计算机名或00511。 ERROR_SHUTDOWN_IN_PROGRESS错误则返回关机已在指定的计算机上的进展。该错误ERROR_NOT_READY可以返回的快速用户切换功能,但没有用户登录。
一个非零返回值并不意味着被注销或将取得成功。关机是一个异步的过程,它可以发生后不久又回到了API调用,或根本没有。即使超时值为零,关机仍然可以胎死腹中的应用,服务,甚至系统。非零返回值表示的权利和参数验证成功,该系统接受了关闭的要求。
要求:
client最低支持Vista
server最低支持 Windows Server 2008
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode和ANSI namesInitiateShutdownW(Unicode)和InitiateShutdownA(ANSI)的
参见
关机
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==InitiateShutdown Function
Initiates a shutdown and restart of the specified computer, and restarts any applications that have been registered for restart.
Syntax
C++
DWORD WINAPI InitiateShutdown(
__in_opt LPTSTR lpMachineName,
__in_opt LPTSTR lpMessage,
__in DWORD dwGracePeriod,
__in DWORD dwShutdownFlags,
__in DWORD dwReason
);
Parameters
lpMachineName [in, optional]
The name of the computer to be shut down. If the value of this parameter is NULL, the local computer is shut down.
lpMessage [in, optional]
The message to be displayed in the interactive shutdown dialog box.
dwGracePeriod [in]
The number of seconds to wait before shutting down the computer. If the value of this parameter is zero, the computer is shut down immediately. This value is limited to MAX_SHUTDOWN_TIMEOUT.
If the value of this parameter is greater than zero, and the dwShutdownFlags parameter specifies the flag SHUTDOWN_GRACE_OVERRIDE, the function fails and returns the error code ERROR_BAD_ARGUMENTS.
dwShutdownFlags [in]
One or more bit flags that specify options for the shutdown. The following values are defined.
ValueMeaning
SHUTDOWN_FORCE_OTHERS
0x00000001 (0x1)All sessions are forcefully logged off. If this flag is not set and users other than the current user are logged on to the computer specified by the lpMachineName parameter, this function fails with a return value of ERROR_SHUTDOWN_USERS_LOGGED_ON.
SHUTDOWN_FORCE_SELF
0x00000002 (0x2)Specifies that the originating session is logged off forcefully. If this flag is not set, the originating session is shut down interactively, so a shutdown is not guaranteed even if the function returns successfully.
SHUTDOWN_GRACE_OVERRIDE
0x00000020 (0x20)Overrides the grace period so that the computer is shut down immediately.
SHUTDOWN_INSTALL_UPDATES
0x00000040 (0x40)The computer installs any updates before starting the shutdown.
SHUTDOWN_NOREBOOT
0x00000010 (0x10)The computer is shut down but is not powered down or rebooted.
SHUTDOWN_POWEROFF
0x00000008 (0x8)The computer is shut down and powered down.
SHUTDOWN_RESTART
0x00000004 (0x4)The computer is shut down and rebooted.
SHUTDOWN_RESTARTAPPS
0x00000080 (0x80)The system is rebooted using the ExitWindowsEx function with the EWX_RESTARTAPPS flag. This restarts any applications that have been registered for restart using the RegisterApplicationRestart function.

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.
Return Value
If the function succeeds, it returns ERROR_SUCCESS.
If the function fails, it returns one of the following error codes.
Return codeDescription
ERROR_ACCESS_DENIEDThe caller does not have the required privilege (SE_SHUTDOWN_PRIVILEGE or SE_REMOTE_SHUTDOWN_PRIVILEGE) to perform this operation.
ERROR_BAD_NETPATHThe specified computer does not exist or is not accessible.
ERROR_INVALID_COMPUTERNAMEThe specified computer name is not a valid computer name.
ERROR_INVALID_FUNCTIONThe specified computer does not support a shutdown interface.
ERROR_INVALID_PARAMETERAn invalid set of parameters was passed. This includes the following combinations.
The lpMachineName parameter specifies a remote computer, and the dwShutdownFlags parameter does not specify SHUTDOWN_FORCE_SELF.
The value of the dwGracePeriod is greater than zero and the dwShutdownFlags parameter does not specify SHUTDOWN_FORCE_SELF.
The value of the dwGracePeriod is greater than zero and the dwShutdownFlags parameter specifies SHUTDOWN_GRACE_OVERRIDE.
ERROR_SHUTDOWN_IN_PROGRESSA shutdown has already been started on the specified computer.
ERROR_SHUTDOWN_IS_SCHEDULEDA shutdown for the specified computer has been scheduled but not started. For this function to succeed, the SHUTDOWN_GRACE_OVERRIDE flag must be set.
ERROR_SHUTDOWN_USERS_LOGGED_ONOne or more users other than the current user are logged on the specified machine, and the SHUTDOWN_FORCE_OTHERS flag was not set.

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.
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesInitiateShutdownW (Unicode) and InitiateShutdownA (ANSI)
See Also
Shutting Down
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa376872(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:22:52