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


Top 5 Contributors of the Month
david stephan

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()
                    mo.Dispose()
                End If
            End If
        Next
        MACID = MACID.Replace(":", "-")
        Return MACID
    End Function
Regards
Hefin Dsouza

     

Further Readings:

Responses

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