+ Reply to Thread
Results 1 to 2 of 2

Thread: Get the Mac-Addresses of a PC

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    11

    Get the Mac-Addresses of a PC

    I am trying to read every single MAC-Address on a pc but i can't figure out how.
    I tried some methods that i found online but they seem to find only one mac-address!

    I'd appreciate if you helped me and thanks.
    Last edited by juniour; 11-08-2012 at 11:16 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    27
    This code will show you the correct way of retrieving every Network interfaces Mac-Address.

    Okay here is the snippet :

    Code:
            using System.Management;
    
            List<string> MacAddresses = new List<string>();
    		
            // The Method
            private void GetMacAddress()
            {
    	 // retrieve each network interface information
                using (var mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
                {
                    foreach (ManagementObject mo in mc.GetInstances())
                    {
                        try
                        {   // get the mac address
                            MacAddresses.Add(mo["MacAddress"].ToString());
                        }
                        catch { }
                    }
                }
            }
    Here i used a list to store each mac-address in , you can after that loop the list to get each mac-address string.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts