简体   繁体   中英

UWP and a List of Serial Devices

Universal Windows Platform uses the following namespace to look at COM and or USB Ports for connected devices: SerialDevice.GetDeviceSelector

This give me a single devices, I would like to get a list of all ports and devices attached.

Is there an ability get a List of devices already connected? For example:

 foreach(var item in SerialDevice.List) 
 {
       var name = item.Name
 }

The goal would be to obtain all the USB devices attached.
Any help is appreciated.

Please check official document

Gets an Advanced Query Syntax (AQS) string that the app can pass to DeviceInformation.FindAllAsync in order to find all serial devices on the system

So, you could get all device with the following code.

var list = await DeviceInformation.FindAllAsync();
foreach (var item in list)
{
    System.Diagnostics.Debug.WriteLine(item.Name);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM