Click here to Skip to main content
15,884,998 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to find the MAC Id of Client Machine
Posted

Hi,

easy to achieve with WMI. Try this:

C#
private string GetMac()
{
    string Mac = string.Empty;
    ManagementClass MC = new ManagementClass("Win32_NetworkAdapter");
    ManagementObjectCollection MOCol = MC.GetInstances();
    foreach (ManagementObject MO in MOCol)
        if (MO != null)
        {
           if (MO["MacAddress"] != null)
                    {
                         Mac = MO["MACAddress"].ToString();
                         if (Mac != string.Empty)
                             break;
                    }
        }
    return Mac;
}


Regards
 
Share this answer
 
v2
Comments
El_Codero 13-Mar-12 8:25am    
This is a full working code sample, just copy/paste it. You need a reference to System.Management Class. Regards
C#
using System.Net.NetworkInformation


private void Form15_Load(object sender, EventArgs e)
      {
         
          NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

          label1.Text = nics[0].GetPhysicalAddress().ToString();

      }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900