[Snippet]GetAdapterInfo

Iniciado por Mi4night, 14 Julio 2010, 10:55 AM

0 Miembros y 1 Visitante están viendo este tema.

Mi4night

Okay Played a little with the WMI today and i thought lets make something useful and done this little function which retrieves various information from active network adapters, hope you guys can use it have fun with it.

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

BlackZeroX


Buena, para recuperar información de configuración de mi tarjeta de Red actual xP.

Dulces Lunas!¡.
The Dark Shadow is my passion.

Mi4night

Bueno, yo use este adaptador para obtener info de mis vecinos :P