手机
当前位置:查字典教程网 >编程开发 >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#把文件转换为XML的代码

C#操作目录与文件的方法步骤

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

C# 获取程序集版本、文件版本

使用SmtpClient发送邮件的方法

C# 打开电子邮件软件的具体方法

.net后台获取html控件值的2种方法

C# TrieTree介绍及实现方法

精品推荐
分类导航