有人可以帮我解决这个问题。我试图用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'代替?感谢