AbortSystemShutdown
请问AbortSystemShutdown有什么用?
是不是可以写个程序让系统不能关机?(除非强制关机/断电)
问题点数:30、回复次数:8Top
1 楼goodname008(卢培培,充电中......)回复于 2003-10-03 20:52:16 得分 5
我手头的资料说是:
停止系统工作。Top
2 楼pigpag(Pigpag - A GRE Fighter)回复于 2003-10-03 21:46:59 得分 0
好像是API列表中的头条吧!一直敬而远之,所以惭愧——不知道。列席旁听Top
3 楼goodname008(卢培培,充电中......)回复于 2003-10-04 10:20:15 得分 0
' 英文还过关吧. :)
AbortSystemShutdown
The AbortSystemShutdown function stops a system shutdown started by using the InitiateSystemShutdown function.
BOOL AbortSystemShutdown(
LPTSTR lpMachineName // pointer to name of computer to stop
// shutting down
);
Parameters
lpMachineName
Pointer to the null-terminated string that specifies the network name of the computer where the shutdown is to be stopped. If lpMachineName is NULL or points to an empty string, the function stops the shutdown on the local computer.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
The InitiateSystemShutdown function displays a dialog box that notifies the user that the system is shutting down. During the InitiateSystemShutdown time-out period, the AbortSystemShutdown function can prevent the system from shutting down.
To stop the local computer from shutting down, the calling process must have the SE_SHUTDOWN_NAME privilege. To stop a remote computer from shutting down, the calling process 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.
Common reasons for failure include an invalid computer name, an inaccessible computer, or insufficient privilege.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winreg.h.
Import Library: Use advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Top
4 楼goodname008(卢培培,充电中......)回复于 2003-10-04 10:20:37 得分 10
InitiateSystemShutdown
The InitiateSystemShutdown function initiates a shutdown and optional restart of the specified computer.
BOOL InitiateSystemShutdown(
LPTSTR lpMachineName, // pointer to name of computer to shut down
LPTSTR lpMessage, // pointer to message to display in
// dialog box
DWORD dwTimeout, // time to display dialog box
BOOL bForceAppsClosed, // force applications closed flag
BOOL bRebootAfterShutdown // reboot flag
);
Parameters
lpMachineName
Pointer to the null-terminated string that specifies the network name of the computer to shut down. If lpMachineName is NULL or points to an empty string, the function shuts down the local computer.
lpMessage
Pointer to a null-terminated string that specifies a message to display in the shutdown dialog box. This parameter can be NULL if no message is required.
dwTimeout
Specifies the time (in seconds) that the dialog box should be displayed. While this dialog box is displayed, the shutdown can be stopped by the AbortSystemShutdown function.
If dwTimeout is not zero, InitiateSystemShutdown 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 a forced shutdown. If the user logs off, the system shuts down immediately. Otherwise, the computer is shut down when the timer expires.
If dwTimeout is zero, the computer shuts down without displaying the dialog box, and the shutdown cannot be stopped by AbortSystemShutdown.
bForceAppsClosed
Specifies whether applications with unsaved changes are to be forcibly closed. If this parameter is TRUE, such applications are closed. If this parameter is FALSE, a dialog box is displayed prompting the user to close the applications.
bRebootAfterShutdown
Specifies whether the computer is to restart immediately after shutting down. If this parameter is TRUE, the computer is to restart. If this parameter is FALSE, the system flushes all caches to disk, clears the screen, and displays a message indicating that it is safe to power down.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
To shut down the local computer, the calling process must have the SE_SHUTDOWN_NAME privilege. To shut down a remote computer, the calling process 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.
Common reasons for failure include an invalid or inaccessible computer name or insufficient privilege.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winreg.h.
Import Library: Use advapi32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Top
5 楼pigpag(Pigpag - A GRE Fighter)回复于 2003-10-04 11:22:39 得分 0
不就是shutdown.exe -a的功能吗?Top
6 楼pigpag(Pigpag - A GRE Fighter)回复于 2003-10-04 11:25:01 得分 10
InitiateSystemShutdown功能也和shutdown.exe一致。就是像中了冲击波一样,由某个用户或系统发起的关机倒计时。
估计AbortSystemShutdown只能取消倒计时,如果倒计时为零了,就不能Abort了Top
7 楼James0001(虾米—什么时候成大虾?)回复于 2003-10-09 08:19:02 得分 5
没多大用,除非你调用了 InitiateSystemShutdown,然后又要取消该操作。
如果因为某些原因使得系统暂时不能关机/注销的话,响应 WM_QUERYENDSESSION 消息(大概响应 QueryUnload 事件也行)。Top
8 楼aha99(学习-工作)回复于 2003-10-09 08:20:58 得分 0
upTop




