IWbemClassObject::SpawnInstance method

Use the IWbemClassObject::SpawnInstance method to create a new instance of a class. The current object must be a class definition obtained from Windows Management using IWbemServices::GetObject, IWbemServices::CreateClassEnum, or IWbemServices::CreateClassEnumAsync Then, use this class definition to create new instances.

A call to IWbemServices::PutInstance is required to actually write the instance to Windows Management. 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 supported but the returned instance will be empty.

Syntax


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

Parameters

lFlags [in]

Reserved. This parameter must be 0.

ppNewInstance [out]

Cannot 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 left unmodified.

Return value

This method returns an HRESULT indicating the status of the method call. The following table lists the value contained within an HRESULT. For general HRESULT values, see System Error Codes.

Return codeDescription
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 Windows Management using PutClass.

WBEM_E_INVALID_PARAMETER

A specified parameter is not valid.

WBEM_E_OUT_OF_MEMORY

There was not enough memory to complete the operation.

WBEM_S_NO_ERROR

The call succeeded.

 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

CIMWin32.dll;
Esscli.dll;
Evntrprv.dll;
Fastprox.dll;
Framedyn.dll;
Krnlprov.dll;
Ncprov.dll;
Wbemcore.dll;
Wbemess.dll;
Wmipiprt.dll

See also

IWbemClassObject
IWbemServices::GetObject
IWbemServices::PutInstance

 

 

Show:
© 2014 Microsoft