VB.NET网络监控具体步骤详解
VB.NET不但可以帮助开发人员实现各种硬件设备信息的产看等功能,还能通过它对网络进行监控。在这里我们就会为大家详细介绍有关VB.NET网络监控的相关操作方法,希望对初学者们有所帮助。
VB.NET网络监控的开发环境:Visual Studio.net 2005
1.在窗体上放置一个TreeView控件,改名为tvInfo。
2.再放置一个按钮控件。
3.双击按钮,编写VB.NET网络监控代码。
- Dim _ManagementObjectSearcher As
New System.Management.Management
ObjectSearcher("SELECT * FROM
Win32_NetworkAdapterConfiguration") - Dim _ParenNode As TreeNode =
Nothing '父节点 - Me.tvInfo.Nodes.Clear()
- Try
- For Each ManObj As System.
Management.ManagementObject
In _ManagementObjectSearcher.Get - _ParenNode = New TreeNode
(ManObj("Description")) - If CBool(ManObj("IPEnabled")) Then
创建 ip地址及子网掩码 子节点
Dim _IpNode As New TreeNode ("IP Address | Default Gateway") If (ManObj("IPAddress") IsNot Nothing) Then For i As Integer = 0 To UBound(ManObj("IPAddress")) _IpNode.Nodes.Add(New TreeNode (ManObj("IPAddress")(i) & " | " & ManObj("IPSubnet")(i))) Next Else _IpNode.Nodes.Add(New TreeNode("Null")) End If
创建 默认网关 子节点
Dim _GatewayNode As New TreeNode("Default Gateway") If (ManObj("DefaultIPGateway") IsNot Nothing) Then For i As Integer = 0 To UBound (ManObj("DefaultIPGateway")) _GatewayNode.Nodes.Add(New TreeNode(ManObj("DefaultIP Gateway")(i))) Next Else _GatewayNode.Nodes.Add(New TreeNode("Null")) End If
创建 DNS服务器地址 子节点
Dim _DNSNode As New TreeNode ("DNS Servers") If (ManObj("DNSServerSearchOrder") IsNot Nothing) Then For i As Integer = 0 To UBound (ManObj("DNSServerSearchOrder")) _DNSNode.Nodes.Add(New TreeNode (ManObj("DNSServerSearchOrder")(i))) Next Else _DNSNode.Nodes.Add(New TreeNode("Null")) End If
_ParenNode.Nodes.AddRange( _ New TreeNode() { _ New TreeNode(String.Format ("Physical Address:{0}", ManObj ("MACAddress"))), _ New TreeNode(String.Format ("DHCPEnabled:{0}", ManObj ("DHCPEnabled"))), _ _IpNode, _ _GatewayNode, _ _DNSNode _ }) End If
相关推荐
kyssfanhui 2020-11-16
tpzmz0 2020-09-16
kudingcha 2020-01-05
tpzmz0 2019-10-27
aflyeaglenku 2019-09-17
明天就流量监控 2019-09-17
技术永不眠Q0 2011-10-09
wangteng 2016-12-27
yhzslwc 2016-10-18
boatman 2015-02-04
流量监控 2018-11-22
borislee0 2016-10-20
82417101 2015-05-18
收银系统安防监控 2017-06-15
花花流量监控 2017-08-04
图流量监控 2017-06-13
图流量监控 2011-11-24
maozishuai 2012-06-17