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 on 2006-02-21 14:44  walker  阅读(305)  评论(0编辑  收藏  举报

导航