C#获取本机可用串口

  • Post author:
  • Post category:其他


http://outofmemory.cn/code-snippet/2574/c-get-benji-keyong-chuankou

public void GetComList()
        {
            RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\DeviceMap\SerialComm");
            if (keyCom != null)
            {
                string[] sSubKeys = keyCom.GetValueNames();
                this.comboBox3.Items.Clear();
                foreach (string sName in sSubKeys)
                {
                    string sValue = (string)keyCom.GetValue(sName);
                    this.comboBox3.Items.Add(sValue);
                }
            }
        }