C#怎么实现Guid算法 获取Mac地址方法

2025-01-19 11:03:17
推荐回答(1个)
回答1:

GUID是由VS2008/2005自动生成!

以下函数获取MAC地址(我平时自己用的):
需要using System.Management;

///


/// Get LocalHost MAC Address
///

///
public string GetHostMacAddress()
{
ManagementClass mc;
string mac = string.Empty;
mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if (mo["IPEnabled"].ToString() == "True")
{
mac = mo["MacAddress"].ToString();
}
}
return mac;
}