获得网卡MAC地址和IP地址(VB.net)

发表于:2007-06-30来源:作者:点击数: 标签:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")

TextBox1.Text = ""

For Each WmiObj As ManagementObject In Wmi.Get

If CBool(WmiObj("IPEnabled")) Then

TextBox1.Text += "IP(" & WmiObj("IPAddress")(0) & ")|MAC(" & WmiObj("MACAddress") & ")" & vbCrLf

End If

Next

End Sub

如果有人运行不出来的话==>首先,引用System.Management;然后在代码中Imports System.Management;

原文转自:http://www.ltesting.net