A version of this page is also available for

Windows Embedded CE 6.0 R3


This function sets the device power state for a device.


DWORD SetDevicePower(
  PVOID pvDevice,
  DWORD dwDeviceFlags,


  • pvDevice
    [in] Specifies the device. Must be a valid LPWSTR device name, for example, "COM1:". This parameter is interpreted according to dwDeviceFlags.
  • dwDeviceFlags
    [in] Set to POWER_NAME to specify the name of the device that is requesting the power request.
  • DeviceState
    [in] Specifies the desired device power state.

Return Value

    Indicates that the caller does not have the required privileges.
    Indicates that the device was not found.
    Indicates an invalid device ID, flag, or dwState value.
    Indicates that the device was found and device power state updated correctly.
    Indicates that the attempt to update the device power failed.


When SetDevicePower is called, qualify the name of your device with an associated class. For example, {8DD679CE-8AB4-43c8-A14A-EA4963FAA715}\DSK1: refers to a power-managed block device called DSK1. If no class qualification is present, the generic power-manageable class {A32942B7-920C-486b-B0E6-92A702A99B35} is assumed.

If you specify a power state that is not supported, the Power Manager will set the device to the next highest supported power level, where D0 is a higher level than D1. However, if you specify D3, the Power Manager will set the device to D4, if D4 is supported. Otherwise the device is set to the next higher supported power level.

Applications should avoid using this function because it greatly restricts device power self-management. They should use the SetPowerRequirement call instead. Set the device power state to PwrDeviceUnspecified to allow normal power management to resume.

See Also

Other Resources

Power Management Functions