共用方式為


SetSystemPowerState

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function sets the system power state to the requested value.

Syntax

DWORD SetSystemPowerState(
  LPCWSTR psState,
  DWORD StateFlags,
  DWORD Options
);

Parameters

  • psState
    [in] Names the desired system state to enter. If this parameter is not NULL, the StateFlags parameter is ignored.
  • StateFlags
    [in] Optional. If the psState parameter is NULL, it names the system power state using the POWER_STATE_XXX flags defined in the Pm.h header file.
  • Options
    [in] Uses the optional POWER_FORCE flag to indicate that the state transfer is urgent. The interpretation of this flag is platform-dependent.

Return Value

  • ERROR_SUCCESS
    Indicates that the system power state has been set successfully.
  • Win32 error code
    Indicates that the system power state was not set.

Remarks

If the requested power state transition causes the system to be suspended, this function returns only after system operation resumes and related PBT_RESUME messages have been broadcast in the POWER_BROADCAST structure. Some platforms may restrict which system power states can be set by applications.

System power states define maximum device power levels for all power-manageable devices in the system. If a device is already at or below the maximum power level mandated by the new system power state, the device power state is not updated.

If a system call explicitly puts the device into an idle state, an appropriate wake source event must be implemented on the target device to activate the device when an application calls SetSystemPowerState(POWER_STATE_SUSPEND).

The POWER_STATE_IDLE flag for the StateFlags parameter is set to Screen off for Windows Mobile devices. In additon, the StateFlags parameter can also be set to the POWER_STATE_USERIDLE state for Windows Mobile devices.

The Options parameter can be set to POWER_DUMPDW to generate a Dr. Watson error report.

See Also

Reference

POWER_BROADCAST

Concepts

Power States

Other Resources

Power Management Functions