IWDFDevice2::RegisterRemoteInterfaceNotification 方法(wudfddi.h)

[警告: UMDF 2 是最新版本的 UMDF,取代了 UMDF 1。 所有新的 UMDF 驱动程序都应使用 UMDF 2 编写。 没有将新功能添加到 UMDF 1,并且对较新版本的 Windows 10 上的 UMDF 1 的支持有限。 通用 Windows 驱动程序必须使用 UMDF 2。 有关详细信息,请参阅 UMDF入门 。]

RegisterRemoteInterfaceNotification 方法注册驱动程序,以在指定的 设备接口 可用时接收通知。

语法

HRESULT RegisterRemoteInterfaceNotification(
  [in] LPCGUID pDeviceInterfaceGuid,
  [in] BOOL    IncludeExistingInterfaces
);

参数

[in] pDeviceInterfaceGuid

指向标识设备接口的 GUID 的指针。

[in] IncludeExistingInterfaces

布尔值。 如果驱动程序将此值设置为 TRUE,则框架会在驱动程序调用 RegisterRemoteInterfaceNotification后通知驱动程序,并且当驱动程序调用 RegisterRemoteInterfaceNotification之前,驱动程序也会通知驱动程序。

如果驱动程序将此值设置为 FALSE,则仅当驱动程序调用 RegisterRemoteInterfaceNotification后设备接口可用时,框架才会通知驱动程序。

返回值

RegisterRemoteInterfaceNotification 返回作S_OK成功。 否则,此方法返回 Winerror.h 包含的另一个值。

言论

仅当驱动程序先前传递给 IWDFDriver::CreateDevice 支持 IPnpCallbackRemoteInterfaceNotification 接口时,驱动程序才能调用 RegisterRemoteInterfaceNotification

有关详细信息,请参阅 在基于 UMDF 的驱动程序中使用设备接口

例子

以下代码示例演示了 IDriverEntry::OnDeviceAdd 回调函数如何注册以通知设备接口的到达。

HRESULT
CMyDriver::OnDeviceAdd(
    __in IWDFDriver  *FxDriver,
    __in IWDFDeviceInitialize  *FxDeviceInit
    )
{
    CComPtr<IWDFDevice> fxDevice;
    HRESULT hr;

    //
    // Create a device object and obtain the IWDFDevice interface.
    //
    hr = FxDriver->CreateDevice(FxDeviceInit,
                                MyDeviceIUnknown,
                                &fxDevice);
    if (FAILED(hr)) goto Error;

    //
    // Obtain the IWDFDevice2 interface from IWDFDevice.
    //
    CComPtr<IWDFDevice2> fxDevice2;
    if (FAILED(hr)) goto Error;
    hr = fxDevice->QueryInterface(IID_PPV_ARGS(&fxDevice2));
    if (S_OK != hr) goto Error;
    //
    // Register for notification when a device interface
    // arrives.
    //
    hr = fxDevice2->RegisterRemoteInterfaceNotification(&GUID_DEVINTERFACE_TOASTER,
                                                        true);
...
}

要求

要求 价值
终止支持 在 UMDF 2.0 及更高版本中不可用。
目标平台 桌面
最低 UMDF 版本 1.9
标头 wudfddi.h (包括 Wudfddi.h)
DLL WUDFx.dll

另请参阅

IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival

IWDFDevice2