当前位置: 编程技术>.net/c#/asp.net
C#获得MAC地址(网卡序列号)的实现代码
来源: 互联网 发布时间:2014-10-28
本文导语: 代码如下: 代码如下://获得网卡序列号 public string GetMoAddress() { string MoAddress = " "; ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection moc2 = mc.GetInstances(); ...
代码如下:
代码如下:
//获得网卡序列号
public string GetMoAddress()
{
string MoAddress = " ";
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc2 = mc.GetInstances();
foreach (ManagementObject mo in moc2)
{
if ((bool)mo["IPEnabled"] == true)
MoAddress = mo["MacAddress"].ToString();
mo.Dispose();
}
return MoAddress.ToString();
}