The SetSystemPowerState function suspends the system by shutting power down. Depending on the ForceFlag parameter, the function either suspends operation immediately or requests permission from all applications and device drivers before doing so.
The calling process must have the SE_SHUTDOWN_NAME privilege. To enable the SE_SHUTDOWN_NAME privilege, use the AdjustTokenPrivileges function. For more information, see Privileges.
Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Long, ByVal fForce As Long) As Long
|Operating Systems Supported|
|Requires Windows 2000 or later; Requires Windows 95 or later|
|· fSuspend |
Windows NT/2000: [in] Specifies the state of the system. If TRUE, the system is suspended. If FALSE, the system hibernates.
Windows 95/98: Ignored.
[in] Forced suspension. If TRUE, the function broadcasts a PBT_APMSUSPEND event to each application and driver, then immediately suspends operation. If FALSE, the function broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation.
|If power has been suspended and subsequently restored, the return value is nonzero.|
If the system was not suspended, the return value is zero. To get extended error information, call GetLastError.