Husam,
There are a million & one pieces of code plastered over the Internet regarding
this using WMI...
Add a Listbox (lstAdapters)
Add reference to System.Management
Use an Import to System.Management
Use the primitive code below:
Private Sub FillNetworkAdapters()
Dim mc As ManagementClass = New
ManagementClass("Win32_NetworkAdapterConfiguration")
Dim mo As ManagementObject
Dim moc As ManagementObjectCollection = mc.GetInstances()
Dim strAdapter As String
Dim strInfo As String
For Each mo In moc
If CBool(mo.Item("IPEnabled")) Then
strAdapter = mo.Item("Caption").ToString().Substring(11)
lstAdapters.Items.Add(String.Format("{0} MAC: {1}",
strAdapter, GetMACAddress(strAdapter)))
End If
Next
End Sub
Private Function GetMACAddress(ByVal Adapter As String) As String
Dim mc As System.Management.ManagementClass
Dim mo As ManagementObject
mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If CBool(mo.Item("IPEnabled")) Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)
If strAdapter = Adapter Then
Return mo.Item("MacAddress").ToString()
End If
End If
Next
End Function
The 'FillNetworkAdapters' get's the name of the adapter & the 'GetMACAddress'
returns the MAC address for that adapter
Sorry but the code can be tidied up considerably as its just part of a project I
wrote back in 2004
=====
Also, never click on these TINY URL's that people paste as they could be hiding
anything. Some spammers & many scammers or webcam prostitutes also use them. Not
saying Patrick is any of these but he could paste in the full url instead, but
wants to know how many fools actually clicked on his links