[C#] 纯文本查看 复制代码 // <summary>
/// 获取mac地址
/// </summary>
/// <returns></returns>
public string getMacAddr_Local()
{
string madAddr = null;
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc2 = mc.GetInstances();
foreach (ManagementObject mo in moc2)
{
if (Convert.ToBoolean(mo["IPEnabled"]) == true)
{
madAddr = mo["MacAddress"].ToString();
madAddr = madAddr.Replace(':', '-');
}
mo.Dispose();
}
return madAddr;
}
一般都是通过IP地址进行通信的
参考:
C#获取Ip地址和MAC地址
http://www.ibcibc.com/forum.php? ... =4223&fromuid=1
|