C#获得机器的Mac地址
2018-07-20 来源:open-open
需要调用windows api,iphlpapi.dll中的方法:
[DllImport("iphlpapi.dll", ExactSpelling = true)]
public static extern int SendARP(int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen);
public string GetMacAddress(string hostName)
{
System.Net.IPAddress[] adrr = Dns.GetHostEntry(hostName).AddressList;
byte[] by = new byte[6];
int len = by.Length;
int r = SendARP((int)adrr[0].Address, 0, by, ref len);
return BitConverter.ToString(by, 0, 6);
}
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:python多线程有几种实现方法
下一篇:iOS简易抽屉效果
最新资讯
热门推荐