WdfUsbTargetDeviceWdmGetConfigurationHandle function

[Applies to KMDF only]

The WdfUsbTargetDeviceWdmGetConfigurationHandle method returns the USBD_CONFIGURATION_HANDLE-typed handle that is associated with the current configuration of a specified USB device.

Syntax

USBD_CONFIGURATION_HANDLE WdfUsbTargetDeviceWdmGetConfigurationHandle(
  WDFUSBDEVICE UsbDevice
);

Parameters

UsbDevice

A handle to a USB device object that was obtained from a previous call to WdfUsbTargetDeviceCreateWithParameters.

Return Value

If the driver has selected a configuration for the device, WdfUsbTargetDeviceWdmGetConfigurationHandle returns the device's USBD_CONFIGURATION_HANDLE-typed handle. Otherwise, the method returns NULL.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

A framework-based driver needs to obtain a USBD_CONFIGURATION_HANDLE-typed handle only if it creates a URB that contains a _URB_SELECT_INTERFACE structure.

The driver can call WdfUsbTargetDeviceWdmGetConfigurationHandle after it has called WdfUsbTargetDeviceSelectConfig. The USBD_CONFIGURATION_HANDLE-typed handle that WdfUsbTargetDeviceWdmGetConfigurationHandle returns is valid until the driver calls WdfUsbTargetDeviceSelectConfig again or the USB device object is deleted. If the driver provides an EvtCleanupCallback function for the USB device object, and if the object is deleted before the driver calls WdfUsbTargetDeviceSelectConfig again, the handle is valid until the object's EvtCleanupCallback function returns.

For more information about the WdfUsbTargetDeviceWdmGetConfigurationHandle method and USB I/O targets, see USB I/O Targets.

Examples

The following code example obtains a handle to the current configuration of a specified USB device.

USBD_CONFIGURATION_HANDLE deviceConfigHdl;

deviceConfigHdl = WdfUsbTargetDeviceWdmGetConfigurationHandle(UsbDevice);

Requirements

   
Target Platform Universal
Minimum KMDF version 1.0
Header wdfusb.h (include Wdfusb.h)
Library Wdf01000.sys (see Framework Library Versioning.)
IRQL "<=DISPATCH_LEVEL"
DDI compliance rules DriverCreate, KmdfIrql, KmdfIrql2, UsbKmdfIrql, UsbKmdfIrql2

See Also

URB

WdfUsbTargetDeviceSelectConfig

_URB_SELECT_INTERFACE