vb.net 教程 7-1 本地网络信息的获取 3 网络连接信息
程序员文章站
2022-05-01 15:56:14
...
通过IPGlobalProperties类可以获得网络连接的信息:
通过GetIPGlobalProperties方法来获得一个IPGlobalProperties实例:
Dim IPGP As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties
具体代码如下:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim IPGP As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties
TextBox1.Text = "DHCP范围名:" & IPGP.DomainName & vbCrLf
TextBox1.Text &= "网络适配器标识符:" & IPGP.DhcpScopeName & vbCrLf
TextBox1.Text &= "主机名:" & IPGP.HostName & vbCrLf
TextBox1.Text &= "WINS代理:" & IPGP.IsWinsProxy & vbCrLf
Dim nodeType As String = ""
Select Case IPGP.NodeType
Case NetBiosNodeType.Broadcast
nodeType = "广播节点"
Case NetBiosNodeType.Hybrid
nodeType = "Hybrid 混合节点"
Case NetBiosNodeType.Mixed
nodeType = "Hybrid 混合节点上"
Case NetBiosNodeType.Peer2Peer
nodeType = "对等节点"
Case NetBiosNodeType.Unknown
nodeType = "未知节点类型"
Case Else
nodeType = "未知状态"
End Select
TextBox1.Text &= "节点类型:" & nodeType & vbCrLf
End Sub
运行如下:
由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供参考。
学习更多vb.net知识,请参看vb.net 教程 目录