您的位置:首页 > 编程语言 > VB

VB.net 2005 读出系统所有串口

2007-11-16 14:38 274 查看
通过读取系统注册表的方法得到所有串口。

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: