.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Code Snippets >> Network >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Retriving the MAC address of a Computer

Posted By:Hefin Dsouza       Posted Date: August 12, 2009    Points: 10    Category: Network    URL: http://www.dotnetspark.com  

This Code Demonstrates the use of ManagementObjects to get the MAC ID of any computer

Public Function GetMACID() As String
        Dim macC As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
        Dim moc As ManagementObjectCollection = macC.GetInstances()
        Dim MACID As String = String.Empty
        For Each mo As ManagementObject In moc
            If (MACID.Equals(String.Empty)) Then
                If CBool(mo("IPEnabled")) Then
                    MACID = mo("MacAddress").ToString()
                End If
            End If
        MACID = MACID.Replace(":", "-")
        Return MACID
    End Function
Hefin Dsouza


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend