UWP 和串行设备列表
UWP and a List of Serial Devices
通用 Windows 平台使用以下命名空间查看已连接设备的 COM 和/或 USB 端口:SerialDevice.GetDeviceSelector
这给了我一个设备,我想获得所有连接的端口和设备的列表。
是否可以获取已连接设备的列表?
例如:
foreach(var item in SerialDevice.List)
{
var name = item.Name
}
目标是获取所有连接的 USB 设备。
任何帮助表示赞赏。
请查看官方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
因此,您可以使用以下代码获取所有设备。
var list = await DeviceInformation.FindAllAsync();
foreach (var item in list)
{
System.Diagnostics.Debug.WriteLine(item.Name);
}
通用 Windows 平台使用以下命名空间查看已连接设备的 COM 和/或 USB 端口:SerialDevice.GetDeviceSelector
这给了我一个设备,我想获得所有连接的端口和设备的列表。
是否可以获取已连接设备的列表? 例如:
foreach(var item in SerialDevice.List)
{
var name = item.Name
}
目标是获取所有连接的 USB 设备。
任何帮助表示赞赏。
请查看官方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
因此,您可以使用以下代码获取所有设备。
var list = await DeviceInformation.FindAllAsync();
foreach (var item in list)
{
System.Diagnostics.Debug.WriteLine(item.Name);
}