如题,怎么获取本地网卡的所有信息,IP地址,网管,DNS,MAC还有网卡名字,还有怎么写IP地址等等。
------解决思路----------------------
Dim here As IPHostEntry = Dns.GetHostEntry(Dns.GetHostName())可以获得IP。其它的你可以类推。
------解决思路----------------------
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = ExecuteCommandSync("ipconfig");
Console.WriteLine(s);
}
static string ExecuteCommandSync(object command)
{
try
{
// create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters.
// Incidentally, /c tells cmd that we want it to execute the command that follows,
// and then exit.
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
// Display the command output.
return result;
}
catch (Exception objException)
{
// Log the exception
return "";
}
}
}
}
------解决思路----------------------
API
GetIfTable
GetAdaptersInfo
GetPerAdapterInfo
GetNetworkParams