Bewerken

Delen via


PoSetPowerState function (wdm.h)

The PoSetPowerState routine notifies the system of a change in the device power state for a device.

Syntax

POWER_STATE PoSetPowerState(
  [in] PDEVICE_OBJECT   DeviceObject,
  [in] POWER_STATE_TYPE Type,
  [in] POWER_STATE      State
);

Parameters

[in] DeviceObject

A pointer to the target DEVICE_OBJECT.

[in] Type

Indicates a POWER_STATE_TYPE value. Drivers must specify DevicePowerState.

[in] State

Specifies the power state to be set. Drivers must specify a DEVICE_POWER_STATE value.

Return value

On Windows 2000 and later versions of the operating system, PoSetPowerState returns the previous power state. On Windows 98/Me, PoSetPowerState returns the state passed in State.

Remarks

PoSetPowerState notifies the power manager of the new power state for a device. Each driver in a device stack (filter, function, and bus drivers) must call PoSetPowerState to inform the power manager of a change in the power state of its corresponding device object. For example:

  • A driver calls this routine after receiving a device set-power request and before calling PoStartNextPowerIrp. When handling a PnP IRP_MN_START_DEVICE request, the driver should call PoSetPowerState to notify the power manager that the device is in the D0 state.
  • If the device is powering down, the driver must call PoSetPowerState before leaving the D0 state. In addition, the driver must be able to process client requests before PoSetPowerState returns.
  • If the device is powering up, the driver must call PoSetPowerState after the device is successfully put into the D0 state.
For more information about powering a device up and down, see Handling IRP_MN_SET_POWER for Device Power States.

Callers of PoSetPowerState must be running at IRQL <= APC_LEVEL except when setting state to D0. When setting state to D0, callers can be running at IRQL <= DISPATCH_LEVEL.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL See Remarks section.

See also

IRP_MN_START_DEVICE

PoStartNextPowerIrp