ManagementObjectSearcher - 来自两个类的交叉引用信息 (c#)
好的..让我们看看我是否能让这个问题有意义:/
我已经做了一个查询,允许我查看所选网卡的 NetworkAdapter 类信息。我想在同一查询中包含来自 NetworkAdapterConfiguration 类的信息(IPAddress、DefaultGateway 等)。请帮忙!!
intquery = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter WHERE Description ='" + comboBox1.Items[comboBox1.SelectedIndex].ToString()+ "'");
ManagementObjectCollection queryCollection = intquery.Get();
queryCollection = intquery.Get();
这是 tcp/ip 信息的另一个查询
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection1 = query.Get();
我可以将它们合并以从同一个组合框中进行选择吗?
非常感谢:)
OK..Lets see if I can make this question make any sense :/
I have made a query that allows me to see NetworkAdapter class information for a selected NIC. I somehow want to include information from the NetworkAdapterConfiguration class in the same query (IPAddress, DefaultGateway etc). PLEEEEEEES HELP!!
intquery = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter WHERE Description ='" + comboBox1.Items[comboBox1.SelectedIndex].ToString()+ "'");
ManagementObjectCollection queryCollection = intquery.Get();
queryCollection = intquery.Get();
This is the other query for tcp/ip info
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection queryCollection1 = query.Get();
Can i merge them to select from the same combo box??
Many Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
Win32_NetworkAdapterSetting
WMI 类,它是一个
关联类
,表示Win32_NetworkAdapterConfiguration
和Win32_NetworkAdapter
类。检查此如何加入 WMI 查询 (WQL)< /code>
查看 Associations 类的工作原理(该链接显示了另一个 WMI 类,但您可以弄清楚如何在您的案例中使用它)
You can use the
Win32_NetworkAdapterSetting
WMI class which is anassociation class
that represents the relationship between theWin32_NetworkAdapterConfiguration
andWin32_NetworkAdapter
classes. check thisHow to join in a WMI Query (WQL)
to see how the Associations class works (the link show another WMI classes, but you can figure out how use it in your case)