IWDFDevice2::CreateRemoteInterface 方法 (wudfddi.h)
[警告: UMDF 2 是最新版本的 UMDF,並取代 UMDF 1。 所有新的UMDF驅動程式都應該使用UMDF 2撰寫。 未將新功能新增至 UMDF 1,而且較新版本的 Windows 10 上對 UMDF 1 的支援有限。 通用 Windows 驅動程式必須使用 UMDF 2。 如需詳細資訊,請參閱 開始使用 UMDF。]
CreateRemoteInterface 方法會建立遠端介面物件,此物件代表 裝置介面。
語法
HRESULT CreateRemoteInterface(
[in] IWDFRemoteInterfaceInitialize *pRemoteInterfaceInit,
[in, optional] IUnknown *pCallbackInterface,
[out] IWDFRemoteInterface **ppRemoteInterface
);
參數
[in] pRemoteInterfaceInit
IWDFRemoteInterfaceInitialize 介面的指標,驅動程式 IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival 回呼函式。
[in, optional] pCallbackInterface
選用驅動程式提供的回呼介面指標。 如果驅動程式支持這些介面,IUnknown::QueryInterface 方法必須傳回驅動程式 IRemoteInterfaceCallbackEvent 和 IRemoteInterfaceCallbackRemoval 介面的指標。 這個參數是選擇性的,而且可以 NULL。
[out] ppRemoteInterface
驅動程式提供位置的指標,接收新遠端介面物件之 IWDFRemoteInterface 介面的指標。
傳回值
如果作業成功,CreateRemoteInterface 會傳回S_OK。 否則,方法可能會傳回下列值:
傳回碼 | 描述 |
---|---|
|
架構嘗試配置記憶體失敗。 |
這個方法可能會傳回 Winerror.h 所包含的其他其中一個值。
言論
如果您的驅動程式呼叫 CreateRemoteInterface,則必須從其 IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival 回呼函式中執行此動作。
如需 CreateRemoteInterface 和使用裝置介面的詳細資訊,請參閱在 UMDF 型驅動程式中使用裝置介面
例子
下列程式代碼範例示範 IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival 回呼函式,該函式會建立遠端介面物件、建立遠端目標物件,並開啟 I/O 作業的遠端目標。
void
STDMETHODCALLTYPE
CMyDevice::OnRemoteInterfaceArrival(
__in IWDFRemoteInterfaceInitialize * FxRemoteInterfaceInit
)
{
HRESULT hr = S_OK;
//
// Create a new remote interface object and provide a callback
// object to handle remote interface events.
//
CComPtr<IWDFRemoteInterface> fxRemoteInterface;
hr = m_FxDevice->CreateRemoteInterface(FxRemoteInterfaceInit,
MyRemoteInterfaceIUnknown,
&fxRemoteInterface);
if (FAILED(hr)) goto Error;
//
// Create a new remote target object and provide a callback
// object to handle remote target events.
//
CComPtr<IWDFRemoteTarget> fxTarget;
hr = m_FxDevice->CreateRemoteTarget(MyRemoteTargetIUnknown,
fxRemoteInterface,
&fxTarget);
if (FAILED(hr)) goto Error;
//
// Open the remote interface with read/write access.
//
hr = FxTarget->OpenRemoteInterface(fxRemoteInterface,
NULL,
GENERIC_READ | GENERIC_WRITE,
NULL);
if (FAILED(hr)) goto Error;
...
}
要求
要求 | 價值 |
---|---|
終止支援 | UMDF 2.0 和更新版本中無法使用。 |
目標平臺 | 桌面 |
最低 UMDF 版本 | 1.9 |
標頭 | wudfddi.h (包括 Wudfddi.h) |
DLL | WUDFx.dll |