如何获取本机Mac

C#中 有没有一个类来获取本机Mac?
---------------------------------------------------------------

http://community.csdn.net/Expert/topic/3414/3414902.xml?temp=.4924127
---------------------------------------------------------------

获得MAC地址的四个方法
http://jiezhi.cnblogs.com/archive/2005/07/13/192066.html
---------------------------------------------------------------

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

}

Published At
Categories with Web编程
Tagged with
comments powered by Disqus