// wdfdevice.h
POWER_ACTION WdfDeviceGetSystemPowerAction(
[in] WDFDEVICE Device
);
View the official Windows Driver Kit DDI referenceNo description available.
[Applies to KMDF and UMDF]
The WdfDeviceGetSystemPowerAction method returns the system power action, if any, that is currently occurring for the computer.
Device [in]A handle to a framework device object.
WdfDeviceGetSystemPowerAction returns a POWER_ACTION-typed enumerator value. The value indicates the system power action that is currently occurring for the computer. For more information, see the following Remarks section. The POWER_ACTION enumeration is defined in wdm.h.
A bug check occurs if the driver supplies an invalid object handle.
Starting in WDF version 1.31/2.31 (referred to as "v31"), WdfDeviceGetSystemPowerAction has been updated to more accurately report system power action when the device is the power policy owner. Drivers need to be recompiled with v31 or later to get the following new behavior:
When the system wakes up from Hybrid Sleep (sleep with a hibernation file), before v31, WdfDeviceGetSystemPowerAction always returned PowerActionHibernate. This is fixed in v31 and now it returns:
The WdfDeviceGetSystemPowerAction method enables a driver to determine whether a device's power transition is occurring because the device is idle (or waking up), or because the entire computer is entering (or leaving) a low-power state.
The driver must call WdfDeviceGetSystemPowerAction only from the event callback functions that the framework calls when the device is entering a low-power state or returning to its working state.
The value that WdfDeviceGetSystemPowerAction returns depends on the following situations:
For more information about low-power states, see A Device Enters a Low-Power State.
The following code example obtains the power transition activity that is currently occurring for the computer.
POWER_ACTION SysPowerAction;
SysPowerAction = WdfDeviceGetSystemPowerAction(device);