IWDFDevice2::CreateRemoteInterface method
The CreateRemoteInterface method creates a remote interface object that represents a device interface.
Syntax
HRESULT CreateRemoteInterface( [in] IWDFRemoteInterfaceInitialize *pRemoteInterfaceInit, [in, optional] IUnknown *pCallbackInterface, [out] IWDFRemoteInterface **ppRemoteInterface );
Parameters
- pRemoteInterfaceInit [in]
- 
A pointer to an IWDFRemoteInterfaceInitialize interface that the driver's IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival callback function received. 
- pCallbackInterface [in, optional]
- 
A pointer to an optional, driver-supplied callback interface. The IUnknown::QueryInterface method of this interface must return a pointer to the driver's IRemoteInterfaceCallbackEvent and IRemoteInterfaceCallbackRemoval interfaces, if the driver supports those interfaces. This parameter is optional and can be NULL. 
- ppRemoteInterface [out]
- 
A pointer to a driver-supplied location that receives a pointer to the IWDFRemoteInterface interface of the new remote interface object. 
Return value
CreateRemoteInterface returns S_OK if the operation succeeds. Otherwise, the method might return the following value:
| Return code | Description | 
|---|---|
| 
 | The framework's attempt to allocate memory failed. | 
This method might return one of the other values that Winerror.h contains.
Remarks
If your driver calls CreateRemoteInterface, it must do so from within its IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival callback function.
For more information about CreateRemoteInterface and using device interfaces, see Using Device Interfaces in UMDF-based Drivers
Examples
The following code example shows an IPnpCallbackRemoteInterfaceNotification::OnRemoteInterfaceArrival callback function that creates a remote interface object, creates a remote target object, and opens the remote target for I/O operations.
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;
...
}
Requirements
| End of support | Unavailable in UMDF 2.0 and later. | 
|---|---|
| Minimum UMDF version | 1.9 | 
| Header | 
 | 
| DLL | 
 | 
See also

