Código:
Option Explicit
'---------------------------------------------------------------------------------------
' Function : GetAdapterInfo
' DateTime : 13.07.2010 12:30PM
' Author : Mi4night
' Mail : mi4night@hotmail.com
' Purpose : Retrieve Network Adapter Information through the WMI
' Usage : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'---------------------------------------------------------------------------------------
Public Function GetAdapterInfo() As Collection
Dim objWMIService As Object
Dim AdapterConfigSet As Object
Dim AdapterConfig As Variant
Dim strComputer As String
Dim NetInfo As String
Dim i As Integer
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set AdapterConfigSet = objWMIService.ExecQuery("Select Caption,DefaultIPGateway,DNSServerSearchOrder,IPAddress,DHCPEnabled,IPSubnet,MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
Set GetAdapterInfo = New Collection
For Each AdapterConfig In AdapterConfigSet
For i = LBound(AdapterConfig.IPAddress) To UBound(AdapterConfig.IPAddress)
GetAdapterInfo.Add "Adapter Name :" & AdapterConfig.Caption(i) & vbCrLf & _
"IP Address :" & AdapterConfig.IPAddress(i) & vbCrLf & _
"Subnet Mask :" & AdapterConfig.IPSubnet(i) & vbCrLf & _
"Default Gateway :" & AdapterConfig.DefaultIPGateway(i) & vbCrLf & _
"DNS Server :" & AdapterConfig.DNSServerSearchOrder(i) & vbCrLf & _
"Mac Address :" & AdapterConfig.MACAddress(i) & vbCrLf & _
"DHCP Enabled :" & AdapterConfig.DHCPEnabled(i) & vbCrLf & vbNewLine
Next
Next
Set objWMIService = Nothing
Set AdapterConfigSet = Nothing
End Function