12 out of 16 rated this helpful Rate this topic

SetSuspendState function

Suspends the system by shutting power down. Depending on the Hibernate parameter, the system either enters a suspend (sleep) state or hibernation (S4).

Syntax

BOOLEAN WINAPI SetSuspendState(
  __in  BOOLEAN Hibernate,
  __in  BOOLEAN ForceCritical,
  __in  BOOLEAN DisableWakeEvent
);

Parameters

Hibernate [in]

If this parameter is TRUE, the system hibernates. If the parameter is FALSE, the system is suspended.

ForceCritical [in]

This parameter has no effect.

Windows Server 2003, Windows XP, and Windows 2000:  If this parameter is TRUE, the system suspends operation immediately; if it is FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation.
DisableWakeEvent [in]

If this parameter is TRUE, the system disables all wake events. If the parameter is FALSE, any system wake events remain enabled.

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

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.

An application may use SetSuspendState to transition the system from the working state to the standby (sleep), or optionally, hibernate (S4) state. This function is similar to the SetSystemPowerState function.

For more information on using PowrProf.h, see Power Schemes. For information about events that can wake the system, see System Wake-up Events.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

PowrProf.h

Library

PowrProf.lib

DLL

PowrProf.dll

See also

Power Management Functions
PBT_APMQUERYSUSPEND
PBT_APMSUSPEND

 

 

Send comments about this topic to Microsoft

Build date: 9/7/2011

Did you find this helpful?
(2000 characters remaining)
Community Content Add
Annotations FAQ
C# Syntax
[DllImport("powrprof.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool SetSuspendState(
[In, MarshalAs(UnmanagedType.I1)] bool Hibernate,
[In, MarshalAs(UnmanagedType.I1)] bool ForceCritical,
[In, MarshalAs(UnmanagedType.I1)] bool DisableWakeEvent
);

PowrProf is part of WDK
PowrProf is a part of the Windows Driver Kit (WDK). And where is that information when you need it??
SetSuspendState does not return until system wakes up
SetSuspendState causes windows to send APMQUERYSUSPEND and APMSUSPEND messages to all running tasks. When the tasks have all responeded (note 20 second limit doumented elsewhere) it suspends the system. *NOTE* that SetSuspendState does not actually RETURN until AFTER the system wakes up from hiberation. You should therefore be careful what thread you call it on. I.e. dont call it on a message thread or on a thread that is otherwise involved in performing the suspend logic for your task.