c#获取远程主机MAC

//获取远程主机MAC //转载请注明来自 http://www.uzhanbao.com

public string getRemoteMac(string localIP, string remoteIP) 
{ 
   Int32 ldest= inet_addr(remoteIP); //目的ip 

   Int32 lhost= inet_addr(localIP); //本地ip


   try 
   { 
    Int64 macinfo = new Int64(); 
    Int32 len = 6; 
    int res = SendARP(ldest,0, ref macinfo, ref len); 
    return Convert.ToString(macinfo,16); 
   } 
   catch(Exception err) 
   { 
    Console.WriteLine("Error:{0}",err.Message); 
   } 
   return 0.ToString();
}

 

你可能感兴趣的:(.net专题)