Private Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
objWMI = GetObject("winmgmts://" & strComputer & "/root/cimv2")
colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNothing(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox("IP 地址:" & IP.IPAddress(I) & Chr(10) & _
"网卡类型:" & IP.Description(I) & Chr(10) & _
"网卡地址:" & IP.Macaddress(I))
Next
End If
Next
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim str As String = ""
GetMyIP()
TextBox6.Text = str
End Sub