DWbemClassObject.Next

[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
 

Parameters

lFlags
Reserved. It must be zero.
pName
A string that will contain the property name. It can be set to vbNullString if you do not need the name.
pVal
This VARIANT is filled with the value of the qualifier. It can be set to NULL if you do not need the value. If an error code is returned, the VARIANT in pVal is left unmodified.
pvtType
Can be NULL. If not NULL, it must be a VARTYPE into which the type of the property is placed. The value of the property can be a VBNULL VARIANT, in which case this parameter would be necessary to determine the actual type of the property. plFlavor

Can be NULL. If not NULL, the Long value receives information on the origin of the property as follows:

WBEM_FLAVOR_ORIGIN_LOCAL
The property belongs to the derived-most class.
WBEM_FLAVOR_ORIGIN_PROPAGATED
The property was inherited from a parent class.
WBEM_FLAVOR_ORIGIN_SYSTEM
The property is a standard system property.

Return Values

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.

Sample Code

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

Remarks

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.

See Also

DWbemClassObject.BeginEnumeration, DWbemClassObject.EndEnumeration, DWbemClassObject.Get, System Properties