问题描述
我想仅从本地计算机获取LAN MAC地址,我的本地计算机具有LAN,无线和蓝牙mac地址,如何仅使用C#获取LAN mac地址,请帮帮我...
字符串macAddress = string.Empty;
字符串deviceCaption = string.Empty;
ManagementClass mgmtClass =新的ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection mgmtObjColl = mgmtClass.GetInstances();
foreach(mgmtObjColl中的ManagementObject mgmtObj){
deviceCaption = mgmtObj ["Caption"].ToString();
macAddress = mgmtObj ["MacAddress"].ToString();
}
使用上面的代码来获取所有以太网卡的mac地址,但我只希望仅局域网mac地址?..
Hi,
I want to get LAN MAC address only from local pc, my local pc has LAN, Wireless and Bluetooth mac address,how to get LAN mac address only using C#,please help me out...
string macAddress = string.Empty;
string deviceCaption = string.Empty;
ManagementClass mgmtClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection mgmtObjColl = mgmtClass.GetInstances();
foreach (ManagementObject mgmtObj in mgmtObjColl) {
deviceCaption = mgmtObj["Caption"].ToString();
macAddress = mgmtObj["MacAddress"].ToString();
}
using above code to get all Ethernet card mac address but i want only LAN mac address only?..
推荐答案
string macAddress = string.Empty;
string deviceCaption = string.Empty;
ManagementClass mgmtClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection mgmtObjColl = mgmtClass.GetInstances();
foreach (ManagementObject mgmtObj in mgmtObjColl) {
deviceCaption = mgmtObj["Caption"].ToString();
macAddress = mgmtObj["MacAddress"].ToString();
}
这篇关于如何获取局域网MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!