/// <summary>
/// 返回本机的mac物理路径
/// </summary>
/// <returns></returns>
private string GetMac()
{
string mac = null;
//[DllImport("System.Management.dll")]
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject mo in queryCollection)
{
if (mo["IPEnabled"].ToString() == "True")
mac = mo["MacAddress"].ToString();
}
return (mac);
}
时间: 2024-10-11 18:19:21