[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
);
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.
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;
}