获取远端mac地址!

hawk5456 2005-05-12 01:30:15
请说的具体一些。
...全文
138 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oyljerry 2005-05-12
  • 打赏
  • 举报
回复
利用iphlp32.dll中的SendARP
skyeenet 2005-05-12
  • 打赏
  • 举报
回复
public class Win32 {
[DllImport("Iphlpapi.dll")]
public static extern int SendARP(Int32 dest,Int32 host,ref IntPtr mac,ref IntPtr length);
[DllImport("Ws2_32.dll")]
public static extern Int32 inet_addr(string ip);
}//调用dll的类

void mac()
{
Int32 ldest= Win32.inet_addr(Request.UserHostAddress);//目的地的ip
Int32 lhost=Win32.inet_addr("190.10.51.5");//本地的ip


try
{
Byte[] macinfo=new Byte[6];
Int32 length=6;

IntPtr mac=new IntPtr(macinfo[0]);
IntPtr len=new IntPtr(6);
int ii=Win32.SendARP(ldest,lhost, ref mac, ref len);


ip+="**mac地址:"+mac.ToString();


}
catch(Exception err)
{
ip+="";
}
}//mac
hedonister 2005-05-12
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3727/3727617.xml?temp=4.088992E-02
http://community.csdn.net/Expert/topic/3738/3738340.xml?temp=.4684107

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧