在C#中相同LAN上的IP地址到MAC地址的IP地址
答
为什么不产生一个进程调用rarp
并从进程的输出读入输入流?这是做一个真正的廉价和简单的方式开朗......*的我的头,它是这样的:
System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo("arp", "-a"); ps.CreateNoWindow = false; ps.RedirectStandardOutput = true; using (System.Diagnostics.Process proc = new System.Diagnostics.Process()) { proc.StartInfo = ps; proc.Start(); System.IO.StreamReader sr = proc.StandardOutput; while (!proc.HasExited) ; string sResults = sr.ReadToEnd(); }
然后,它的解析sResults
获得MAC地址的问题。
答
如果你正在寻找一个基于API的方法并不能做的Process.Start()来看看这个:
http://www.codeproject.com/KB/IP/host_info_within_network.aspx
它允许主机名,IP地址的映射和MAC地址。
重复问题:http://*.com/questions/1148778/how-do-i-access-arp-protocol-information- through-c-net – mjv 2010-02-05 00:53:32