hopeless

导航

获取串口列表

/// <summary>
        /// 获取COM列表
        /// </summary>
        public static  void GetComList(ComboBox comboBox)
        {
            RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
            if (keyCom != null)
            {
                string[] sSubKeys = keyCom.GetValueNames();
                comboBox.Items.Clear();
                foreach (string sName in sSubKeys)
                {
                    string sValue = (string)keyCom.GetValue(sName);
                    comboBox.Items.Add(sValue);
                }
                comboBox.SelectedIndex = 0;
            }
        }

posted on 2009-08-15 11:28  hopeless  阅读(561)  评论(0编辑  收藏  举报