手机
当前位置:查字典教程网 >编程开发 >C#教程 >用C#编写获取远程IP,MAC的方法
用C#编写获取远程IP,MAC的方法
摘要:如果要想获得远程的地址,需要用sendarp这个函数来实现。具体的代码如下:[DllImport("Iphlpapi.dll")]priva...

如果要想获得远程的地址,需要用sendarp这个函数来实现。具体的代码如下:

[DllImport("Iphlpapi.dll")]

privatestaticunsafeexternintSendARP(Int32dest,Int32host,refIntPtrmac,refIntPtrlength);

[DllImport("Ws2_32.dll")]

privatestaticexternInt32inet_addr(stringip);

Int32ldest=inet_addr("157.60.68.163");//目的地的ip

Int32lhost=inet_addr("157.60.68.33");//本地的ip

try

{

Byte[]macinfo=newByte[6];

Int32length=6;

IntPtrmac=newIntPtr(macinfo[0]);

IntPtrlen=newIntPtr(6);

intii=SendARP(ldest,lhost,refmac,reflen);

Console.WriteLine("MacAdd:"+mac);

Console.WriteLine("length:"+len);

}

catch(Exceptionerr)

{

Console.WriteLine(err);

}

【用C#编写获取远程IP,MAC的方法】相关文章:

C#中一些你可能没用过的调试窗口的方法

C#简单获取时间差的小例子

C#中使用IrisSkin2.dll美化WinForm程序界面的方法

C#实现窗体淡入淡出效果的方法总结

C#获取全部目录和文件的简单实例

C# 向二进制文件进行读写的操作方法

C# 运用params修饰符来实现变长参数传递的方法

关于C#程序优化的五十种方法

用C#获取硬盘序列号,CPU序列号,网卡MAC地址的源码

C# 格式化字符首字母大写的方法

精品推荐
分类导航