手机
当前位置:查字典教程网 >编程开发 >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# TrieTree介绍及实现方法

配置C#的系统环境变量的方法

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

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

获取字符串中的汉字拼音首字母

C#操作注册表的方法

C#中将ListView中数据导出到Excel的实例方法

C#几种获取网页源文件代码的实例

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

用C#把文件转换为XML的代码

精品推荐
分类导航