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();
}