27 lines
706 B
C#
27 lines
706 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Management;
|
|
|
|
namespace Zhaizj.Framework.Utils
|
|
{
|
|
public class MacGet
|
|
{
|
|
public static 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();
|
|
}
|
|
str = str.Replace(':', '-');
|
|
return str;
|
|
}
|
|
}
|
|
}
|