Click here to Skip to main content
13,193,970 members (49,535 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
How to find the MAC Id of Client Machine
Posted 13-Mar-12 2:00am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

using System.Net.NetworkInformation
 

private void Form15_Load(object sender, EventArgs e)
      {
         
          NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
 
          label1.Text = nics[0].GetPhysicalAddress().ToString();
 
      }
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

easy to achieve with WMI. Try this:

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
  Permalink  
v2
Comments
Björn Ranft 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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171018.2 | Last Updated 1 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100