开发者

ManagementObjectSearcher - Cross Reference information from two classes (c#)

开发者 https://www.devze.com 2023-02-13 08:53 出处:网络
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 someh开发者_C百科ow want to include informa

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 someh开发者_C百科ow 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 :)


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消