IWbemClassObject::SpawnInstance

[This is preliminary documentation and subject to change.]

Use the IWbemClassObject::SpawnInstance method to create a new instance of a class. The current object must be a class definition obtained from CIMOM using IWbemServices::GetObject or IWbemServices::CreateClassEnum. Then, use this class definition to create new instances. Each new instance is created locally within the process, and a call to IWbemServices::PutInstance is required to actually create the instance within CIMOM.

If you intend to discard the object before calling IWbemServices::PutInstance, simply make a call to IWbemClassObject::Release

Note that spawning an instance from an instance is legal.

HRESULT IWbemClassObject::SpawnInstance(
  [in] LONG lFlags,
  [out] IWbemClassObject **ppNewInstance
);
 

Parameters

lFlags
Reserved. It must be zero.
ppNewInstance
Must not be NULL. It receives a new instance of the class. The caller must invoke IWbemClassObject::Release when the pointer is no longer required. On error, a new object is not returned and the pointer is set to point to NULL.

Return Values

WBEM_E_INCOMPLETE_CLASS The current object is not a valid class definition and cannot spawn new instances. Either it is incomplete, or it has not been registered with CIMOM using PutClass.
WBEM_E_ILLEGAL_OPERATION Returned if this method is used on an instance instead of a class
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_NO_ERROR Success.

See Also

IWbemServices::GetObject, IWbemServices::PutInstance