-api-id | -api-type |
---|---|
N:Windows.Devices.Usb |
winrt namespace |
This namespace defines Windows Runtime classes that a UWP app can use to communicate with WinUSB devices. These devices are handled by the inbox winusb.sys
driver and are identified by a specific Microsoft OS Descriptor.
A valid WinUSB device will have a compatible id of USB\MS_COMP_WINUSB
This namespace supports most WinUSB devices. However, it does not provide access to USB devices with device classes of the following:
- Audio (
0x01
) - HID (
0x03
) - Image (
0x06
) - Printer (
0x07
) - Mass Storage (
0x08
) - Smart Card (
0x0B
) - Audio/Video (
0x10
) - Wireless Controller (
0xE0
)
A UWP app that accesses a USB device must include specific device capability data in the capabilities node of its manifest. This data identifies the device and its purpose (or function). Note that some devices may have multiple functions.
Since Windows 10, version 1809 (October 2018 Update)
<DeviceCapability Name="usb"/>
Before Windows 10, version 1809 (October 2018 Update)
Since 1809, the VendorId/ProductId and function-type no longer need to be specified and will be ignored on newer systems. If targeting systems below 1809, then see legacy USB device capabilities.
- Verify the USB capability (
usb
) is in the application manifest. - Verify the user has granted permission for the application to utilize USB devices.
- Validate the device type is not one designated as inaccessible.
- Machine-internal devices (
DEVPKEY_Device_InLocalMachineContainer == TRUE
) are generally not accessible unless running on a SKU with embedded mode andlowLevelDevices
capability. - Devices with stacks that contain upper/lower filter drivers are generally not accessible. These are sometimes added by 3rd parties to enable additional functionality for custom hardware.
- Device restriction is partially determined by
winusb.sys
during device enumeration, which may set the device interface propertyDEVPKEY_DeviceInterface_Restricted
toTRUE
on the WinUSB Device InterfaceGUID_DEVINTERFACE_WINUSB_WINRT
based on the presence of device/class filters. - The presence of device UpperFilter/LowerFilter drivers can be determined using DeviceManager by looking for
UpperFilters
andLowerFilters
properties. - The presence of WinUSB class UpperFilter/LowerFilter drivers can be determined using DeviceManager by looking for
Class upper filters
andClass lower filters
properties. - Device Interface properties can be inspected by calling
CM_Get_Device_Interface_Property
wherepszDeviceInterface
is the same string as would be passed to FromIdAsync.
- Device restriction is partially determined by
- These restrictions can be bypassed when making a custom device by working with the driver-developer to create a Hardware Support App
Talking to USB devices, start to finish (UWP app), Custom USB device sample (Windows 10)