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