c# 读取mck码

private List<string> GetMac()
{
List<string> macs = new List<string>();
try
{
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
var moc = mc.GetInstances();
foreach (var mo in moc)
{
if (!(bool)mo["IPEnabled"])
continue;
var mac = mo["MacAddress"].ToString();
macs.Add(mac);
}
}
catch
{
}
return macs;
}

posted @ 2016-08-20 15:33  mysuper  阅读(142)  评论(0编辑  收藏  举报