Archive for the ‘Code Snippets’ Category

Getting MAC Address in .Net

Monday, March 5th, 2007

Below is the VB.Net snippet to retrieve MAC address available on your machine.

‘Add reference to system.management

Imports System.Management

Private Sub GetMACAddress()

Dim oMClass As ManagementClass = New _ ManagementClass(”Win32_NetworkAdapterConfiguration”)
Dim colMObj As ManagementObjectCollection = oMClass.GetInstances()

For Each objMO As ManagementObject In colMObj
console.WriteLine (objMO(”MacAddress”).ToString)
Next

End Sub

If you like this post, you may want to subscribe to my RSS feed.