如何抓取客户端(client)的MAC(网卡编号)
只需要使用以下代码就行,有几张网卡就跑几次,一定要在网卡启动的情况下,不然抓不到.
ManagementObjectSearcher query =new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration") ;
ManagementObjectCollection queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection )
{
if(mo["IPEnabled"].ToString() == "True")
MessageBox.Show(mo["MacAddress"].ToString());
}
ManagementObjectCollection queryCollection = query.Get();
foreach( ManagementObject mo in queryCollection )
{
if(mo["IPEnabled"].ToString() == "True")
MessageBox.Show(mo["MacAddress"].ToString());
}