Bewerken

Delen via


SWbemObject.Instances_ method

The Instances_ method of the SWbemObject object creates an enumerator that returns the instances of the current class object. This method implements a simple query. More complex queries may require the use of SWbemServices.ExecQuery.

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

Syntax

objWbemObjectSet = .Instances_( _
  [ ByVal iFlags ], _
  [ ByVal objwbemNamedValueSet ] _
)

Parameters

iFlags [in, optional]

Integer that determines the behavior of the call. This parameter can accept the following values.

wbemFlagForwardOnly (32 (0x20))

Causes a forward-only enumerator to be returned. Forward-only enumerators are generally much faster and use less memory than conventional enumerators, but they do not allow calls to SWbemObject.Clone_.

wbemFlagBidirectional (0 (0x0))

Causes WMI to retain pointers to objects of the enumeration until the client releases the enumerator.

wbemFlagReturnImmediately (16 (0x10))

Default value for this parameter. This flag causes the call to return immediately.

wbemFlagReturnWhenComplete ( 0 (0x0))

Causes this call to block until the query has completed.

wbemQueryFlagShallow (1 (0x1))

Forces the enumeration to include only immediate subclasses of the specified parent class.

wbemQueryFlagDeep (0 (0x0))

Default for this parameter. This value forces the enumeration to include all classes in the hierarchy.

wbemFlagUseAmendedQualifiers (131072 (0x20000))

Causes WMI to return class amendment data with the base class definition.

objwbemNamedValueSet [in, optional]

Typically, this is undefined. Otherwise, this is an SWbemNamedValueSet object whose elements represent the context information that can be used by the provider that is servicing the request. A provider that supports or requires such information must document the recognized value names, data type of the value, allowed values, and semantics.

Return value

If the method is successful, an SWbemObjectSet object returns.

Error codes

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

wbemErrAccessDenied - 2147749891 (0x80041003)

Current user does not have permission to view instances of the specified class.

wbemErrFailed - 2147749889 (0x80041001)

Unspecified error occurred.

wbemErrInvalidClass - 2147749904 (0x80041010)

Specified class is not valid.

wbemErrInvalidParameter - 2147749896 (0x80041008)

A specified parameter is not valid.

wbemErrOutOfMemory - 2147749894 (0x80041006)

Not enough memory to complete the operation.

Remarks

The Instances_ method only works for class objects. It is not an error for the returned collection to have zero elements. The default behavior for this method is semisynchronous because of the default IFlags value wbemFlagReturnImmediately.

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

SWbemObjectSet