1. 程式人生 > >C#獲取本機可用串列埠

C#獲取本機可用串列埠

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);
                }
            }
        }