[This is preliminary documentation and subject to change.]
The DWbemClassObject.Next method retrieves the next property in an enumeration that was started with DWbemClassObject.BeginEnumeration. This should be called repeatedly to enumerate all the properties until WBEM_S_NO_MORE_DATA is returned. If the enumeration is to be terminated early, call DWbemClassObject.EndEnumeration.
The order of the properties returned during the enumeration is not defined.
DWbemClassObject.Next(
[in] lFlags As Long,
[out, OPTIONAL] pName As String,
[out, OPTIONAL] pVal As VARIANT,
[out, OPTIONAL] pvtType As Long,
[out, OPTIONAL] plFlavor As Long
) As Long
Can be NULL. If not NULL, the Long value receives information on the origin of the property as follows:
WBEM_E_INVALID_PARAMETER | An invalid parameter was specified, or the namespace could not be parsed. |
WBEM_E_OUT_OF_MEMORY | There was not enough memory to complete the operation. |
WBEM_E_UNEXPECTED | Did not call DWbemClassObject.BeginEnumeration. |
WBEM_NO_ERROR | Success. |
WBEM_S_NO_MORE_DATA | No more properties are left in the enumeration. |
Private Sub gather_desktop_data()
' This Subroutine fills a listbox with the desktop configurations.
Dim ppEnum As DIEnumWbemClassObject
Dim ppObject As DWbemClassObject
Dim pVal As Variant
If wbem_logon <> WBEM_NO_ERROR Then 'logon Subroutine failed
MsgBox ("Unable to log on to namespace")
Exit Sub
End If
' ppNamespace is a DIWbemServices type object bound to the
' specified namespace in wbem_logon
ppNamespace.CreateInstanceEnum "Win32_desktop", WBEM_FLAG_DEEP, Nothing, ppEnum
While ppEnum.Next(1000, ppObject) <> WBEM_S_FALSE
ppObject.Get "__RELPATH", 0, pVal, 0, 0
Listbox.AddItem pVal 'add to a listbox
Wend
Set ppEnum = Nothing 'Set the object back to nothing
End Sub
If the underlying type of the property is an object path, a date/time, or another special type, the returned type does not contain enough information. The caller must examine the CIMTYPE qualifier for the specified property, and determine if the property is an object reference, date/time, or another special type.
This method also returns system properties.
DWbemClassObject.BeginEnumeration, DWbemClassObject.EndEnumeration, DWbemClassObject.Get, System Properties