Mac address

  • Thread starter Thread starter UJ
  • Start date Start date
You have to make P/Invoke on
GetAdaptersInfo(...) function which is located in Iphlpapi.dll.

Watch the docs for more details
 
If you can navigate the Management classes, WMI, try something like this:

string servername = ".";
ManagementScope ms = new ManagementScope("\\\\" + servername +
"\\root\\cimv2");
ManagementPath mp = new ManagementPath("Win32_NetworkAdapterConfiguration");
ObjectGetOptions o = new ObjectGetOptions();
ManagementClass mc = new ManagementClass(ms, mp, o);
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
{
Console.WriteLine("NIC: "+mo["description"]);
Console.WriteLine("MAC address\t{0}", mo["MacAddress"].ToString());
}
}

This gets my MAC address ok, at mo["MacAddress"].
 
Back
Top