C# C语言中NIC卡的连接列表#
我的系统中安装了两个网络接口卡,我想要连接到特定NIC卡的所有计算机的列表,或者我需要一个类似于DOS中“arp-a”命令的代码。我需要一个C#代码来做这件事。请帮助我。如果您只需要从C# C语言中NIC卡的连接列表#,c#,ip-address,connection,arp,nic,C#,Ip Address,Connection,Arp,Nic,我的系统中安装了两个网络接口卡,我想要连接到特定NIC卡的所有计算机的列表,或者我需要一个类似于DOS中“arp-a”命令的代码。我需要一个C#代码来做这件事。请帮助我。如果您只需要从arp-a输出,那么这很简单: Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true;
arp-a
输出,那么这很简单:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "arp.exe";
p.StartInfo.Arguments = "-a";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
MessageBox.Show(output); //etc... parse this for what you need
当然,您需要添加:
using System.Diagnostics;
我认为您必须编写一个C接口来访问硬件信息。除非你能读ping。