Редагувати

Поділитися через


SWbemObject.SpawnInstance_ method

Use the SpawnInstance_ method of the SWbemObject object to create a new instance of a class. The current object must be a class definition obtained from WMI via a method such as SWbemServices.Get or SWbemServices.ExecQuery. Then, use this class definition to create new instances. Create each new instance locally within the process, and then call SWbemObject.Put_ to actually create the instance within WMI.

Note

Spawning an instance from an instance is supported, but the returned instance is empty.

For an explanation of this syntax, see Document Conventions for the Scripting API.

Syntax

objNewInstance = .SpawnInstance_( _
  [ ByVal iFlags ] _
)

Parameters

iFlags [in, optional]

Reserved and must be zero if specified.

Return value

If successful, this call returns an SWbemObject object that contains a new instance of the class.

Error codes

After the completion of the SpawnInstance_ method, the Err object may contain one of the error codes in the following list.

wbemErrIncompleteClass - 2147749920 (0x80041020)

Current object is not a valid class definition, and it cannot spawn new instances. Either it is incomplete, or it has not been registered with WMI using SWbemObject.Put_.

wbemErrIllegalOperation - 2147749918 (0x8004101E)

Returned if this method is used on an instance instead of a class.

wbemErrInvalidParameter - 2147749896 (0x80041008)

Invalid parameter was specified.

wbemErrOutOfMemory - 2147749894 (0x80041006)

Not enough memory to complete the operation.

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemObject
IID
IID_ISWbemObject

See also

SWbemObject

SWbemObject.Put_

SWbemServices.Get