c# 在ASP。NET 如何提取客户端的网卡MAC地址
我写了这样一个方法:/// <summary>
/// 获取MAC地址
/// </summary>
/// <returns></returns>
public string GetNetCardMacAddress()
{
ManagementClass mc;
ManagementObjectCollection moc;
mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
moc = mc.GetInstances();
string str = "";
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
str = mo["MacAddress"].ToString();
}
return str;
}
注意要引用using System.Management;命名空间
页:
[1]