IEnumWbemClassObject interface

The IEnumWbemClassObject interface is used to enumerate Common Information Model (CIM) objects and is similar to a standard COM enumerator.

An object of type IEnumWbemClassObject is received from calls to the following methods:

CIM objects are retrieved from an enumeration as objects of type IWbemClassObject by calling the Next method. You can reset an enumeration back to the beginning by calling the Reset method.


The IEnumWbemClassObject interface inherits from the IUnknown interface. IEnumWbemClassObject also has these types of members:


The IEnumWbemClassObject interface has these methods.

Method Description
IEnumWbemClassObject::Clone The IEnumWbemClassObject::Clone method makes a logical copy of the entire enumerator, retaining its current position in an enumeration.
IEnumWbemClassObject::Next Use the IEnumWbemClassObject::Next method to get one or more objects starting at the current position in an enumeration.
IEnumWbemClassObject::NextAsync Use the NextAsync method when a controlled asynchronous retrieval of objects to a sink is required.
IEnumWbemClassObject::Reset The IEnumWbemClassObject::Reset method resets an enumeration sequence back to the beginning. Because CIM objects are dynamic, calling this method does not necessarily return the same list of objects that you obtained previously.
IEnumWbemClassObject::Skip You can use the IEnumWbemClassObject::Skip method to move the current position in an enumeration ahead by a specified number of objects. Also, this affects subsequent calls to NextAsync, but it does not affect pending deliveries begun with NextAsync.


IEnumWbemClassObject is the object returned from a WMI query, and is used to enumerate through the returned values. For more information on how to use this class, see Querying WMI and Enumerating WMI.


The following C++ code sample describes how to retrieve an IEnumWbemClassObject.

void ExecQuerySync(IWbemServices *pSvc)
    // Query for all users and groups.

    BSTR Language = SysAllocString(L"WQL");
    BSTR Query = SysAllocString(L"SELECT * FROM __Namespace");

    // Initialize the IEnumWbemClassObject pointer.
    IEnumWbemClassObject *pEnum = 0;

    // Issue the query.
    HRESULT hRes = pSvc->ExecQuery(
        WBEM_FLAG_FORWARD_ONLY,         // Flags
        0,                              // Context


    if (hRes != 0)
    ULONG uTotal = 0;

    // Retrieve the objects in the result set.
    for (;;)
        IWbemClassObject *pObj = 0;
        ULONG uReturned = 0;

        hRes = pEnum->Next(
            0,                  // Time out
            1,                  // One object

        uTotal += uReturned;

        if (uReturned == 0)

        // Use the object.
        // ...
        // Release it.
        // ===========
        pObj->Release();    // Release objects not owned.            

    // All done.


Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header wbemcli.h (include Wbemidl.h)

See also


Enumerating WMI