c#获得串口列表

之前从网上当到的,从注册表里面获取
【c#获得串口列表】C#获取串口列表
//using Microsoft.Win32;
public void GetComList()
{
RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
if (keyCom != null)
{
string[] sSubKeys = keyCom.GetValueNames();
this.cmbComPort.Items.Clear();
foreach (string sName in sSubKeys)
{
string sValue = https://www.it610.com/article/(string)keyCom.GetValue(sName);
this.cmbComPort.Items.Add(sValue);
}
}
}
转载于:https://www.cnblogs.com/shenzhenhua/p/5117528.html

    推荐阅读