【发布时间】:2023-04-07 12:22:01
【问题描述】:
美好的一天。
(netsh interface show interface)中有4个分类栏
管理状态(启用)
状态(断开)或(连接)
类型(专用)
接口名称(以太网 2)或(Wi-Fi)或(以太网)
问题 1: 如何获取我的接口名称 where State = "Connected";
ManagementClass mc = new ManagementClass("Win32_NetworkAdapter");
foreach (ManagementObject mo in mc.GetInstances())
{
int index = Convert.ToInt32(mo["Index"]);
string name = mo["NetConnectionID"] as string;
if (!string.IsNullOrEmpty(name))
MessageBox.Show(name);
//textBox1.Text += name + Environment.NewLine;
}
我在这里有我想输出的图像。 Sample Image
谢谢你们。
【问题讨论】:
标签: c# networking