DIWbemServices.ExecQuery

[This is preliminary documentation and subject to change.]

The DIWbemServices.ExecQuery method executes a query to retrieve objects. These objects are available through the returned enumerator. All query results return through the enumerator as DIEnumWbemClassObject.

For the valid types of queries that can be performed, see Queries.

DIWbemServices.ExecQuery(
  [in] QueryLanguage As String,             
  [in] Query As String,                     
  [in] lFlags As Long,                    
  [in] pCtx As Object,              
  [out] ppEnum As Object 
) As Long
 

Parameters

QueryLanguage
A string containing one of the query languages supported by CIMOM. This must be "WQL" for the WBEM Query Language.
Query
A string containing the text of the query. This cannot be vbNullString.
lFlags
Reserved. It must be zero.
pCtx
Typically NOTHING. Otherwise, this is a DWbemContext object required by the dynamic class provider that is producing the class instances. The values in the context object in the documentation for the provider in question.

If the query is very broad and involves many instance providers, it is not practical to include enough context information for all providers. In these situations, the parameter should be set to NOTHING.

ppEnum
If no error occurs, this parameter receives the enumerator that allows the caller to retrieve the instances in the result set of the query. It is not an error for the query to have a result set with zero instances, and only by attempting to iterate through the instances can this be determined.

Return Values

WBEM_E_ACCESS_DENIED The current user does not have permission to view the result set.
WBEM_E_FAILED Unspecified error.
WBEM_E_INVALID_PARAMETER An invalid parameter was specified or the namespace could not be parsed.
WBEM_E_INVALID_QUERY The query was not syntactically valid.
WBEM_E_INVALID_QUERY_LANGUAGE The requested query language is not supported.
WBEM_E_OUT_OF_MEMORY There was not enough memory to complete the operation.
WBEM_NO_ERROR Success.

For more information on return values see Visual Basic error handeling and return values.

See Also

Error Objects, DIWbemServices.ExecQueryAsync, Queries