As the title, I just need Ethernet network adapter's physical address to create password. Viusal studio 2010 C#, Windows 7 professional
Had tried different way but failed.
Seems each solution just catch the enabled one.
As attached sample1, I had tried sort by spercial word, but not every ethernet adapter description has "PCI"
Attached sample2 is the way to get the enable adapter MAC address, unuseful either.
How can i get the ethernet adapter physical address when the computer is working in wireless network?
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
string MACAddress = String.Empty;
foreach (ManagementObject mo in moc)
if (MACAddress == String.Empty) // only return MAC Address from first card
if ((bool)mo["IPEnabled"] == true) MACAddress = mo["MacAddress"].ToString();
MACAddress = MACAddress.Replace(":", "");
NetworkInterface fNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in fNetworkInterfaces)
string strDescription = adapter.Description.ToString();
//the MAC address which has "PCI" and not has "Wireless" is ethernet MAC
if (strDescription.Contains("PCI") && !strDescription.Contains("Wireless"))
strMAC = adapter.GetPhysicalAddress().ToString();