Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function notifies Power Manager that an application has a specified device power requirement.

Syntax

HANDLE SetPowerRequirement(
  PVOID 
pvDevice,
  CEDEVICE_POWER_STATE 
DeviceState,
  ULONG 
DeviceFlags,
  PVOID
 pvSystemState,
  ULONG
 StateFlags
);

Parameters

pvDevice

[in] Specifies the device. Must be a valid LPWSTRdevice name, for example, "COM1:". The meaning is determined by the Flagsparameter.

DeviceState

[in] Specifies the minimum device power state from the CEDEVICE_POWER_STATEenumeration at which to maintain the device.

DeviceFlags

[in] Bitwise-OR of the following flags.

Flag Description

POWER_FORCE

Indicates that the requirement should be enforced even during a system suspend.

POWER_NAME

Specifies the name of the device whose power should be maintained at or above the DeviceStatelevel.

pvSystemState

[in] If not set to null, indicates that the requirement should only be enforced for the named system power state.

StateFlags

[in] Unused. Set to zero.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

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

Applications and drivers should always explicitly release their power requirements as soon as they cease to be necessary. Power Manager automatically releases the requirement if the calling process exits for any reason before ReleasePowerRequirementis called.

If multiple SetPowerRequirementcalls have been made for a single device, the actual power requirement imposed by Power Manager is the one that consumes more power. For example, if one application requires at least device power state D1 and another requires at least device power state D2, Power Manager maintains the device at D1.

See Also