0
微軟的文章,ManagementBaseObject.Properties
房產,顯示瞭如何收集枚舉屬性在vb.net收集
For Each p As PropertyData In properties
Console.WriteLine(p.Name)
For Each q As QualifierData In p.Qualifiers
If (q.Name.Equals("Description")) Then
Console.WriteLine(processClass.GetPropertyQualifierValue(.Name, q.Name))
End If
Next
Console.WriteLine()
Next
End Function
和第http://msdn.microsoft.com/en-us/library/ms257359.aspx演示從WMI retreiving信息中列舉的屬性。
我想要做的是運行一個WMI查詢,如「SELECT * FROM Win32_Environment」。但我似乎無法通過集合枚舉,因爲ENVVAR不是PropertyDataCollection:
Dim query As New ObjectQuery(strQuery)
Dim searcher As New ManagementObjectSearcher(scope, query)
For Each queryObj As ManagementObject In searcher.Get()
s = s & queryObj("Name").ToString() & ": " & queryObj("VariableValue").ToString()
Next
我如何通過這個集合枚舉不知道名字嗎?由於queryObj不是一個集合,我似乎無法讓它工作。
謝謝!這樣做:) – simon