SetSystemPowerState function (winbase.h)
[SetSystemPowerState is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Applications written for Windows Vista and later should use SetSuspendState instead.]
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.
BOOL SetSystemPowerState( [in] BOOL fSuspend, [in] BOOL fForce );
If this parameter is TRUE, the system is suspended. If the parameter is FALSE, the system hibernates.
This parameter has no effect.
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.
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 Changing Privileges in a Token.
If any application or driver denies permission to suspend operation, the function broadcasts a PBT_APMQUERYSUSPENDFAILED event to each application and driver. If power is suspended, this function returns only after system operation is resumed and related WM_POWERBROADCAST messages have been broadcast to all applications and drivers.
This function is similar to the SetSuspendState function.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the Windows Headers.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|
|Header||winbase.h (include Windows.h)|