IoUnregisterPlugPlayNotificationEx 函式 (wdm.h)

IoUnregisterPlugPlayNotificationEx 例程會取消驅動程式回呼例程的註冊,以取得 隨插即用 (PnP) 事件的通知。

語法

NTSTATUS IoUnregisterPlugPlayNotificationEx(
  [in] PVOID NotificationEntry
);

參數

[in] NotificationEntry

表示要取消之註冊的不透明值的指標。 呼叫端先前藉由呼叫 IoRegisterPlugPlayNotification 例程來取得此值。

傳回值

如果 NotificationEntry 參數有效,IoUnregisterPlugPlayNotificationEx 會傳回STATUS_SUCCESS。

備註

核心模式驅動程式會呼叫此例程,以移除註冊以接收 PnP 通知。 也就是說, IoUnregisterPlugPlayNotificationEx 呼叫會取消一個 PnP 事件類別目錄的驅動程式回呼例程註冊。 驅動程式先前已藉由呼叫 IoRegisterPlugPlayNotification 例程來取得此註冊。

IoUnregisterPlugPlayNotificationEx 呼叫傳回之後,就會取消指定的註冊,而且不會再發生任何回呼。

IoUnregisterPlugPlayNotification 例程類似於 IoUnregisterPlugPlayNotificationEx,不同之處在於它無法保證 IoUnregisterPlugPlayNotification 呼叫傳回之後不會發生進一步的回呼。

驅動程式通常會從通知回呼例程呼叫 IoUnregisterPlugPlayNotificationEx 。 在大部分情況下,驅動程式可以透過這種方式安全地刪除通知回呼例程的註冊。 不過,如果下列兩者都成立,通知回呼例程呼叫 IoUnregisterPlugPlayNotificationEx 來取消註冊本身是不安全的:

  • 驅動程式會在提供給註冊通知回呼例程之 IoRegisterPlugPlayNotification 呼叫的 EventCategoryFlags 參數值中設定PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES旗標。

  • 註冊通知回呼例程的 IoRegisterPlugPlayNotification 呼叫尚未傳回。

回呼例程不得呼叫任何可能會封鎖回呼例程執行所在線程的例程。 例如,如果設計不佳的回呼例程會在工作專案佇列中放置呼叫 IoUnregisterPlugPlayNotificationEx 的工作專案,然後等候背景工作線程完成工作專案,則會導致操作系統死結。

驅動程式應該先取消通知回呼例程的註冊,然後釋放與例程相關聯的任何內容緩衝區。

除非驅動程式移除其所有 PnP 通知註冊,否則無法卸除驅動程式,因為每個作用中註冊都會保留驅動程式 物件的 計數參考,代表驅動程式的載入映像。

如需詳細資訊,請參閱 使用 PnP 通知

規格需求

需求
最低支援的用戶端 從 Windows 7 開始提供。
目標平台 Universal
標頭 wdm.h (包括 Wdm.h、Ntddk.h、Ntifs.h)
程式庫 NtosKrnl.lib
Dll NtosKrnl.exe
IRQL PASSIVE_LEVEL
DDI 合規性規則 HwStorPortProhibitedDDIs (storport) PowerIrpDDis (wdm)

另請參閱

IoRegisterPlugPlayNotification

IoUnregisterPlugPlayNotification