Compartilhar via


GetDevicePower

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function returns the current power state for a device.

Syntax

DWORD GetDevicePower(
  PVOID pvDevice,
  DWORD dwDeviceFlags,
  PCEDEVICE_POWER_STATE pDeviceState
);

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 either POWER_NAME or POWER_FORCE.

    Set to POWER_NAME to specify the name of the device that is requesting the power request.

    Set to POWER_FORCE to cause Power Manager to issue an IOCTL_POWER_GET to the device, rather than returning the internally cached power state for the named device.

Return Value

  • ERROR_SUCCESS
    Indicates success.

Remarks

When GetDevicePower 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.

The cached power state equals the last power state requested using SetDevicePower. Power Manager checks whether the driver supports the requested power state. If not, Power Manager maps the requested power state to a power state that the driver does support. Therefore, the cached power state may not match the actual power state sent to the driver with IOCTL_POWER_SET. Because passing POWER_NAME to GetDevicePower returns the cached power state, what GetDevicePower retrieves may not equal the last power state sent to the driver using IOCTL_POWER_SET.

Besides being called by user code, SetDevicePower is also called internally by Power Manager. Therefore, GetDevicePower may return the power state last requested by the user, or it may return the last power state Power Manager requested using SetDevicePower.

See Also

Reference

CEDEVICE_POWER_STATE
IOCTL_POWER_GET
IOCTL_POWER_SET
SetDevicePower

Other Resources

Power Management Functions