获取对方的mac
获取对方的mac using System;using System.Runtime.InteropServices;class Program{[DllImport("Iphlpapi.dll")] private sta
获取对方的mac
using System;
using System.Runtime.InteropServices;
class Program
{
[DllImport("Iphlpapi.dll")]
private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);
static private Int64 getRemoteMAC(string remoteIP)
{
Int32 ldest= inet_addr(remoteIP); //目的地的ip
try
{
Int64 macinfo = new Int64();
Int32 len = 6;
int res = SendARP(ldest,0, ref macinfo, ref len);
return macinfo;
}
catch(Exception err)
{
Console.WriteLine("Error:{0}",err.Message);
}
return 0;
}
static void Main()
{
Console.Write("I P:");
Int64 mac=getRemoteMAC(Console.ReadLine());
Console.WriteLine("MAC:{0}",Convert.ToString(mac,16));
}
}
本文作者:佚名 来源:http://www.51blog.net
CIO之家 www.ciozj.com 微信公众号:imciow
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读