共用方式為


WdfDeviceInitSetPowerPolicyEventCallbacks 函式 (wdfdevice.h)

[適用於 KMDF 和 UMDF]

WdfDeviceInitSetPowerPolicyEventCallbacks 方法會註冊驅動程式的電源原則事件回呼函式。

語法

void WdfDeviceInitSetPowerPolicyEventCallbacks(
  [in] PWDFDEVICE_INIT                   DeviceInit,
  [in] PWDF_POWER_POLICY_EVENT_CALLBACKS PowerPolicyEventCallbacks
);

參數

[in] DeviceInit

呼叫端提供的 WDFDEVICE_INIT 結構的指標。

[in] PowerPolicyEventCallbacks

呼叫端初始化 WDF_POWER_POLICY_EVENT_CALLBACKS 結構的指標。

傳回值

備註

如果您的驅動程式呼叫 WdfDeviceInitSetPowerPolicyEventCallbacks,它必須先這麼做,才能呼叫 WdfDeviceCreate。 如需詳細資訊,請參閱 建立架構裝置物件

如需 WdfDeviceInitSetPowerPolicyEventCallbacks 的詳細資訊,請參閱 Power Policy 擁有權

範例

下列程式代碼範例會初始化 WDF_POWER_POLICY_EVENT_CALLBACKS 結構,然後呼叫 WdfDeviceInitSetPowerPolicyEventCallbacks

WDF_POWER_POLICY_EVENT_CALLBACKS powerPolicyCallbacks;

WDF_POWER_POLICY_EVENT_CALLBACKS_INIT(&powerPolicyCallbacks);
powerPolicyCallbacks.EvtDeviceArmWakeFromS0 = PciDrvEvtDeviceWakeArmS0;
powerPolicyCallbacks.EvtDeviceDisarmWakeFromS0 = PciDrvEvtDeviceWakeDisarmS0;
powerPolicyCallbacks.EvtDeviceWakeFromS0Triggered = PciDrvEvtDeviceWakeTriggeredS0;
powerPolicyCallbacks.EvtDeviceArmWakeFromSx = PciDrvEvtDeviceWakeArmSx;
powerPolicyCallbacks.EvtDeviceDisarmWakeFromSx = PciDrvEvtDeviceWakeDisarmSx;
powerPolicyCallbacks.EvtDeviceWakeFromSxTriggered = PciDrvEvtDeviceWakeTriggeredSx;
WdfDeviceInitSetPowerPolicyEventCallbacks(
                                          DeviceInit,
                                          &powerPolicyCallbacks
                                          );

規格需求

需求
目標平台 Universal
最低 KMDF 版本 1.0
最低UMDF版本 2.0
標頭 wdfdevice.h (包含 Wdf.h)
程式庫 Wdf01000.sys (KMDF) ;WUDFx02000.dll (UMDF)
IRQL <= DISPATCH_LEVEL
DDI 合規性規則 ChildDeviceInitAPI (kmdf) DeviceInitAPI (kmdf) DriverCreate (kmdf) FDOPowerPolicyOwnerAPI (kmdf) KmdfIrql (kmdf) KmdfIrql2 (kmdf) 、KmdfIrqlExplicit (kmdf) 、 NonFDONotPowerPolicyOwnerAPI (kmdf) PdoDeviceInitAPI (kmdf)

另請參閱

WDF_POWER_POLICY_EVENT_CALLBACKS_INIT

WdfDeviceInitSetPnpPowerEventCallbacks