用C#编写获取远程IP,MAC的方法
来源:互联网 发布:2016年中国关税数据 编辑:程序博客网 时间:2024/05/14 10:23
如果要想获得远程的地址,需要用sendarp这个函数来实现。具体的代码如下:
[DllImport("Iphlpapi.dll")]
private static unsafe extern int SendARP(Int32 dest,Int32 host,ref IntPtr mac,ref IntPtr length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);
Int32 ldest= inet_addr("157.60.68.163");//目的地的ip
Int32 lhost= inet_addr("157.60.68.33");//本地的ip
try
{
Byte[] macinfo=new Byte [ 6];//
Int32 length=6;
IntPtr mac=new IntPtr(macinfo[0]);
IntPtr len=new IntPtr(6);
int ii=SendARP(ldest,lhost, ref mac, ref len);
Console.WriteLine("Mac Add:"+mac);
Console.WriteLine("length:"+len);
}
catch(Exception err)
{
Console.WriteLine(err);
}
- 用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- (轉)用C#编写获取远程IP,MAC的方法
- 用C#编写获取远程IP,MAC的方法
- C#编程之 如何获取本地和远程主机的IP及MAC地址
- C#编程之 如何获取本地和远程主机的IP及MAC地址
- C#编程之 如何获取本地和远程主机的IP及MAC地址
- 获取远程主机MAC地址的方法
- c#获取远程主机MAC
- C#自用获取本机IP,MAC方法
- C# ManagementObjectSearcher方法获取IP和MAC地址
- c#获取远程主机IP
- 利用IP,用C#来获得远程主机的MAC地址
- c#获取远程主机的MAC地址(转贴)
- U.S. Textile Executives Complain about China
- C#操作XML初步
- U.S. Eyes Textile Pact with China
- ASP.NET动态生成HTML页面
- Why my update method dose not work?
- 用C#编写获取远程IP,MAC的方法
- Perl 网上资源
- 18个HTML小技巧
- 数据库应用基础系列
- Win32 APIs 资源 for .net
- C#基础语法
- 一个中型OA系统的架构过程(一)
- 网址收藏
- 收集