Imports Microsoft.Win32
Private Sub Formmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
Dim comValue As String
Dim comreg As RegistryKey = Registry.LocalMachine
Dim returnValue As RegistryKey
ComboBox1.Items.Clear()
Dim hklm As RegistryKey = Registry.LocalMachine
Dim software11 As RegistryKey = hklm.OpenSubKey("HARDWARE")
''打開"HARDWARE"子健
Dim software As RegistryKey = software11.OpenSubKey("DEVICEMAP")
Dim sitekey As RegistryKey = software.OpenSubKey("SERIALCOMM")
Dim Str2() As String = sitekey.GetValueNames()
''獲得當前子健下面所有健組成的字符串數組
Dim ValueCount As Integer = sitekey.ValueCount
''獲得當前子健存在多少健值
Dim j As Integer
For j = 0 To ValueCount - 1
ComboBox1.Items.Add(sitekey.GetValue(Str2(j)))
''在下拉列表中加入所有健值
Next j
ComboBox1.Text = My.Settings.Default.comSetting
End Sub