SerialDevice.GetDeviceSelectorFromUsbVidPid(UInt16, UInt16) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an Advanced Query Syntax (AQS) string that the app can pass to DeviceInformation.FindAllAsync in order to find a specific Serial-to-USB device by specifying its VID and PID.
public:
static Platform::String ^ GetDeviceSelectorFromUsbVidPid(unsigned short vendorId, unsigned short productId);
static winrt::hstring GetDeviceSelectorFromUsbVidPid(uint16_t const& vendorId, uint16_t const& productId);
public static string GetDeviceSelectorFromUsbVidPid(ushort vendorId, ushort productId);
function getDeviceSelectorFromUsbVidPid(vendorId, productId)
Public Shared Function GetDeviceSelectorFromUsbVidPid (vendorId As UShort, productId As UShort) As String
Parameters
- vendorId
-
UInt16
unsigned short
uint16_t
Specifies the vendor identifier for the device as assigned by the USB specification committee. Possible values are 0 through 0xffff.
- productId
-
UInt16
unsigned short
uint16_t
Specifies the product identifier. This value is assigned by the manufacturer and is device-specific. Possible values are 0 through 0xffff.
Returns
String formatted as an AQS query.
Examples
This example code shows how to get the SerialDevice object by specifying the vendor/product Id of the Serial-to-USB device.
protected override async void OnLaunched1(LaunchActivatedEventArgs args)
{
UInt32 vid = 0x045E;
UInt32 pid = 0x078F;
string aqs = SerialDevice.GetDeviceSelectorFromUsbVidPid(vid, pid);
var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs, null);
if (myDevices.Count == 0)
{
ShowError("Device not found!");
return;
}
using SerialDevice device = await SerialDevice.FromIdAsync(myDevices[0].Id);
}