MAC地址在C#中同一局域网中的IP地址 [英] MAC address to IP Address on Same LAN in C#

查看:125
本文介绍了MAC地址在C#中同一局域网中的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找到在C#中的IP地址,MAC地址之间的映射。我认为RARP应该能够做到这一点,有没有一个在C#中,一个API

Is there a way to find mapping between MAC address to IP address in C#. i think RARP should be able to do that, is there an API available in C# for that

推荐答案

为什么不产生一个过程调用 RARP 键,从进程的输出输入流中读取?这是做一个真正的廉价和简单的方式开朗......顶级的我的头,它是这样的:

Why not spawn a process to invoke rarp and read in the input stream from the process's output? That's a real cheap simple and cheerful way of doing it...top-of-my-head, it goes something like this:


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地址。

这篇关于MAC地址在C#中同一局域网中的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆