C#中得到网卡号

using System.Management;

//get the MAC address

ManagementClass mc=new ManagementClass("Win32_NetworkAdapterConfiguration");

ManagementObjectCollection moc=mc.GetInstances();

string[] MacAddress=new string[2];

int ii=0;

foreach(ManagementObject mo in moc)

{

 if((bool)mo["IPEnabled"]==true)

 {

 MacAddress[ii]=mo["MacAddress"].ToString();

 ii++;

 }

mo.Dispose();

}

posted @ 2010-11-18 14:16  落冰  阅读(266)  评论(0编辑  收藏  举报