Compartilhar via


SetDevicePower

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function sets the device power state for a device.

Syntax

DWORD SetDevicePower(
  PVOID pvDevice,
  DWORD dwDeviceFlags,
  CEDEVICE_POWER_STATE DeviceState
);

Parameters

  • 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

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

Remarks

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