IWDFDevice::CreateDeviceInterface method

The CreateDeviceInterface method creates an instance of a device interface class.

Syntax


HRESULT CreateDeviceInterface(
  [in]            LPCGUID pDeviceInterfaceGuid,
  [in, optional]  PCWSTR  pReferenceString
);

Parameters

pDeviceInterfaceGuid [in]

A pointer to the GUID for a device interface class.

pReferenceString [in, optional]

A pointer to a NULL-terminated string that contains the name of the instance of the device interface. This parameter is optional. The driver can pass NULL if the driver does not have to supply a name. If the driver must supply a name, the string that the driver passes must not contain any path separator characters ("/" or "\").

Return value

CreateDeviceInterface returns S_OK if the operation succeeds. Otherwise, this method returns one of the error codes that are defined in Winerror.h.

Remarks

Drivers can use the pReferenceString parameter to differentiate different instances of a single interface. In other words, if a driver calls CreateDeviceInterface twice for the same device interface class, the driver can specify a different string for pReferenceString each time. When an instance of an interface is opened, the framework passes the instance's reference string to the driver. The reference string is appended to the path component of the interface instance's name. The driver can then use the reference string to determine which instance of the device interface class is being opened.

If CreateDeviceInterface succeeds, the initial state of the interface is disabled. If creation succeeds, the framework automatically enables and disables the interface based on the device's PnP state. In addition, a driver can disable and re-enable a device interface as necessary by calling IWDFDevice::AssignDeviceInterfaceState.

For more information about device interfaces, see Using Device Interfaces in UMDF-based Drivers.

Examples

The following code example shows how to create a device interface instance. In this example, the driver explicitly calls IWDFDevice::AssignDeviceInterfaceState to enable the interface.


    //
    // Create the device interface.
    //
    HRESULT hr;
    if (S_OK == hr) {
        hr = m_FxDevice->CreateDeviceInterface(
                         &GUID_DEVINTERFACE_OSRUSBFX2,
                         NULL);
    }
    if (S_OK == hr) {
        hr = m_FxDevice->AssignDeviceInterfaceState(
                        &GUID_DEVINTERFACE_OSRUSBFX2,
                        NULL,
                        TRUE);
    }

Requirements

Target platform

Desktop

End of support

Unavailable in UMDF 2.0 and later.

Minimum UMDF version

1.5

Header

Wudfddi.h (include Wudfddi.h)

DLL

WUDFx.dll

See also

IWDFDevice
IWDFDevice::AssignDeviceInterfaceState

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft