IEnumWbemClassObject::Clone

[This is preliminary documentation and subject to change.]

The IEnumWbemClassObject::Clone method makes a logical copy of the entire enumerator, retaining its current cursor position. This method will make only a "best effort" copy. Due to the dynamic nature of many CIM objects, it is possible that the new enumerator does not enumerate the same set of objects as the source enumerator.

Note  Any pending asynchronous deliveries begun by NextAsync are not cloned.

HRESULT Clone(
  [out] IEnumWbemClassObject **ppEnum 
);
 

Parameters

ppEnum
Receives a pointer to a new IEnumWbemClassObject object. The caller must call Release when the interface pointer is no longer required. On error, there will not be a return of a new object.

Return Values

S_OK The call succeeded, and the enumerator has been cloned.
S_FALSE The call failed, and no enumerator has been returned.

On error, you can call the COM function GetErrorInfo to obtain more error information.

Sample Code

BOOL CloneEnum(IEnumWbemClassObject *pSrc)
{
    IEnumWbemClassObject *pCopy = 0;

    HRESULT hRes = pSrc->Clone(&pCopy);

    if (hRes != S_OK)       // Failed to clone it
        return FALSE;

    // Use the copy of the enumerator
    // ...

    pCopy->Release();

    return TRUE;
}