GetAdapterInfoWMI

Okay today i have nothing to do,so I’m doing a lot of stuff some of those are funny so boring anyway this is one of the funny stuff that came out.
It’s a function with retrieves a thew information about your active network adapters you maybe find it useful.

Option Explicit
‘—————————————————————————————
‘ Function : GetAdapterInfoWMI
‘ DateTime : 13.07.2010 12:30PM
‘ Author : Kreshnik Hasanaj
‘ Mail : kresha7@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 GetAdapterInfoWMI() 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 GetAdapterInfoWMI = New Collection
For Each AdapterConfig In AdapterConfigSet

For i = LBound(AdapterConfig.IPAddress) To UBound(AdapterConfig.IPAddress)

GetAdapterInfoWMI.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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s