我正在使用此代码:
NetworkInformation.NetworkInterface[] interfaces = NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
以上代码仅检索活动网络连接,我需要全部。我是怎么做到的 提前致谢。 :)
答案 0 :(得分:3)
using System.Management;
ManagementObjectSearcher query = new ManagementObjectSearcher(
"SELECT * FROM Win32_NetworkAdapterConfiguration" );
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject mo in queryCollection)
{
Console.WriteLine(mo["Description"].ToString());
}
编辑:
找到所有其他人["属性"]名称,改变这样的foreach:
foreach (ManagementObject mo in queryCollection)
{
foreach (PropertyData pd in mo.Properties)
{
Console.WriteLine(pd.Name);
}
}