The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
UsbDevice.GetDeviceClassSelector | getDeviceClassSelector method
Gets an Advanced Query Syntax (AQS) string that the app can pass to DeviceInformation.FindAllAsync in order to find a specific type of USB device.
Syntax
Public Shared Function GetDeviceClassSelector( usbClass As UsbDeviceClass ) As String
Parameters
- usbClass
-
Type: UsbDeviceClass
A UsbDeviceClass object for the device class specified by the app.
Return value
Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]
String formatted as an AQS query.
Remarks
You can search for a UsbDevice in the enumerated collection of devices by specifying class code, sub class code, or protocol code. To do this,
- Create a UsbDeviceClass object by specifying ClassCode, SubclassCode, and ProtocolCode property values. Alternatively, you can call the constructor by specifying a particular UsbDeviceClasses property.
- Call GetDeviceClassSelector and pass that new class. The call retrieves an AQS string.
- Call FindAllAsync and pass the string to get the UsbDevice object.
Examples
protected override async void OnLaunched(LaunchActivatedEventArgs args) { byte deviceClass = 0xf0; byte deviceSubclass = 0x01; var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync( UsbDevice.GetDeviceClassSelector( new UsbDeviceClass() { Class = deviceClass, Subclass = deviceSubclass })); UsbDevice device = null; foreach (var device in myDevices) { if (IsMyDevice(device)) { device = await UsbDevice.FromIdAsync(device.Id); } } if (device == null) { ShowError("Usb device not found"); return; } }
Requirements
Minimum supported client | Windows 8.1 |
---|---|
Minimum supported server | Windows Server 2012 R2 |
Namespace |
|
Metadata |
|
See also
Show: