Mac address

V

Vadym Stetsyak

You have to make P/Invoke on
GetAdaptersInfo(...) function which is located in Iphlpapi.dll.

Watch the docs for more details
 
P

Phil Wilson

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"].
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top