ManagementObjectSearcher - 来自两个类的交叉引用信息 (c#)

发布于 2024-10-19 04:45:50 字数 760 浏览 2 评论 0原文

好的..让我们看看我是否能让这个问题有意义:/

我已经做了一个查询,允许我查看所选网卡的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一花一树开 2024-10-26 04:45:50

您可以使用Win32_NetworkAdapterSettingWMI 类,它是一个 关联类,表示 Win32_NetworkAdapterConfigurationWin32_NetworkAdapter 类。检查此如何加入 WMI 查询 (WQL)< /code>查看 Associations 类的工作原理(该链接显示了另一个 WMI 类,但您可以弄清楚如何在您的案例中使用它)

You can use the Win32_NetworkAdapterSetting WMI class which is an association class that represents the relationship between the Win32_NetworkAdapterConfiguration and Win32_NetworkAdapter classes. check this How 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文