使用C#使用WMI查询填充组合框

时间:2014-06-18 06:46:00

标签: c# combobox wmi

有人可以帮我解决这个问题。我试图用WMI查询中的值填充组合框。但我不知道该怎么做。谷歌搜索找到解决方案但无济于事。

private void Form_Load1(object sender, EventArgs e)
{
    ManagementScope oScope = new ManagementScope("\\root\\cimv2");
    ObjectQuery oQuery = new ObjectQuery("select DisplayName from Win32_Service");
    ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oScope, oQuery);
    ManagementObjectCollection oCol = oSearcher.Get();


          foreach (ManagementObject col in oCol)
          {
              String displayName = col["DisplayName"].ToString();

              comboBox1.Items.Add(displayName);


          }

我更改为foreach循环,但它显示所有属性值。如何选择' DisplayName'代替?感谢

0 个答案:

没有答案
相关问题