SWbemServices.InstancesOf method
Applies to: desktop apps only
The InstancesOf method of the SWbemServices object creates an enumerator that returns the instances of a specified class according to the user-specified selection criteria. This method implements a simple query. More complex queries may require the use of SWbemServices.ExecQuery.
The method is called in the semisynchronous mode. For more information, see Calling a Method.
For an explanation of this syntax, see Document Conventions for the Scripting API.
Syntax
objWbemObjectSet = .InstancesOf( _ ByVal strClass, _ [ ByVal iFlags ], _ [ ByVal objWbemNamedValueSet ] _ )
Parameters
- strClass
-
Required. String that contains the name of the class for which instances are desired. This parameter cannot be blank.
- iFlags [optional]
-
This parameter determines how deep the call enumerates and if this call returns immediately. The default value for this parameter is wbemFlagReturnImmediately. This parameter can accept the following values.
Value Meaning - 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. This flag calls the method in the synchronous mode.
- wbemQueryFlagShallow
- 1 (0x1)
Forces the enumeration to include only immediate subclasses of the specified parent class.
- wbemQueryFlagDeep
- 0 (0x0)
Default value 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. For more information, see Localizing WMI Class Information.
- objWbemNamedValueSet [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 successful, the method returns an SWbemObjectSet.
Error codes
Upon the completion of the InstancesOf method, the Err object may contain one of the error codes in the following table.
Note A returned enumerator with zero elements is not an error.
| Error (Name/Dec/Hex) | Meaning |
|---|---|
|
Current user does not have the permission to view instances of the specified class. |
|
Unspecified error occurred. |
|
Specified class is not valid. |
|
A specified parameter is not valid. |
|
Not enough memory to complete the operation. |
Remarks
The InstancesOf method only works for class objects.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Type library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/9/2012