IEnumWbemClassObject::Clone method
The IEnumWbemClassObject::Clone method makes a logical copy of the entire enumerator, retaining its current position in an enumeration. This method makes 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 When the enumeration is initialized with the WBEM_FLAG_FORWARD_ONLY flag, IEnumWbemClassObject::Clone is not supported.
Any pending asynchronous deliveries begun by NextAsync are not cloned.
Syntax
HRESULT Clone( [out] IEnumWbemClassObject **ppEnum );
Parameters
- ppEnum [out]
-
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 value
This method returns an HRESULT indicating the status of the method call.
On error, you can call the COM function GetErrorInfo to obtain more error information. COM-specific error codes may also be returned if network problems cause you to lose the remote connection to Windows Management.
The following table lists the value contained within an HRESULT.
| Return code | Description |
|---|---|
|
An unspecified error occurred. |
|
The caller passed an invalid parameter. |
|
There was not enough memory to complete the operation. |
|
This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management. |
|
The call succeeds and the current position was updated. |
Remarks
Because the call-back to the sink might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous communication instead of asynchronous. If you require asynchronous communication, see Calling a Method.
For more information about using methods semisynchronously, see IEnumWbemClassObject and Calling a Method.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
The following code shows how to use the IEnumWbemClassObject::Clone method.
BOOL CloneEnum(IEnumWbemClassObject *pSrc)
{
IEnumWbemClassObject *pCopy = 0;
HRESULT hRes = pSrc->Clone(&pCopy);
if (hRes != WBEM_S_NO_ERROR) // Failed to clone it.
return FALSE;
// Use the copy of the enumerator.
// ...
pCopy->Release();
return TRUE;
}
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
Send comments about this topic to Microsoft
Build date: 11/19/2012