IWbemQuery::GetAnalysis method

The IWbemQuery::GetAnalysis method gets the results of a successful query parse.

Syntax


HRESULT GetAnalysis(
  [in]   ULONG  uAnalysisType,
  [in]   ULONG  uFlags,
  [out]  LPVOID *pAnalysis
);

Parameters

uAnalysisType [in]

Type of analysis to get.

Analysis type (constant or value)Meaning
WMIQ_ANALYSIS_RPN_SEQUENCE
1

Used if the query has a SELECT clause. When this type of analysis is used, pAnalysis points to an SWbemRpnEncodedQuery structure.

WMIQ_ANALYSIS_ASSOC_QUERY
2

Used to return information about association type queries. When this type of analysis is used, pAnalysis points to an SWbemAssocQueryInf structure.

WMIQ_ANALYSIS_PROP_ANALYSIS_MATRIX
3

Unused. Reserved for future use.

WMIQ_ANALYSIS_QUERY_TEXT
4

Used to return a text string that has the original query text. If this type of analysis is used, pAnalysis points to a text string that contains the original query text.

You can use this parameter if a parser object is passed to another method.

 

uFlags [in]

Reserved for future use.

pAnalysis [out]

Pointer to the analysis generated by a call to IWbemQuery::GetAnalysis. It is important to free up this memory by calling IWbemQuery::FreeMemory.

Return value

This method returns an HRESULT that indicates the status of a method call.

Return codeDescription
WBEM_S_NO_ERROR

Method successfully analyzes a query.

WBEM_E_INVALID_OPERATION

Nothing was parsed, or an incorrect type of analysis is specified. For example, requesting association information on a non-association query.

WBEM_E_INVALID_QUERY

The query is not valid.

WBEM_E_INVALID_PARAMETER

The uAnalysisType argument value is not valid.

WBEM_E_OUT_OF_MEMORY

Out of memory.

 

Examples

The following code example shows a query analysis by using WMIQ_ANALYSIS_RPN_SEQUENCE.


IWbemQuery *pQuery = NULL;
HRESULT hr = NULL;
hr = CoCreateInstance(CLSID_WbemQuery,
                      0,
                      CLSCTX_INPROC_SERVER,
                      IID_IWbemQuery,
                      (LPVOID *)&pQuery);


SWbemRpnEncodedQuery *pRpn = NULL;
hr = pQuery->GetAnalysis(WMIQ_ANALYSIS_RPN_SEQUENCE,
                         0,
                         (LPVOID *)&pRpn);
// -- do something
pQuery->FreeMemory(pRpn);

The following code example shows a query analysis by using WMIQ_ANALYSIS_ASSOC_QUERY.


IWbemQuery *pQuery = NULL;
HRESULT hr = NULL;
hr = CoCreateInstance(CLSID_WbemQuery,
                      0,
                      CLSCTX_INPROC_SERVER,
                      IID_IWbemQuery,
                      (LPVOID *)&pQuery);


SWbemAssocQueryInf *pAssoc = NULL;
hr = pQuery->GetAnalysis(WMIQ_ANALYSIS_ASSOC_QUERY,
                         0,
                         (LPVOID *)&pAssoc);
// -- do something
pQuery->FreeMemory(pAssoc);

The following code example shows a query analysis by using WMIQ_ANALYSIS_QUERY_TEXT.


IWbemQuery *pQuery = NULL;
HRESULT hr = NULL;
hr = CoCreateInstance(CLSID_WbemQuery,
                      0,
                      CLSCTX_INPROC_SERVER,
                      IID_IWbemQuery,
                      (LPVOID *)&pQuery);


WCHAR *pText = NULL;
hr = pQuery->GetAnalysis(WMIQ_ANALYSIS_QUERY_TEXT,
                         0,
                         (LPVOID *)&pText);
// -- do something
pQuery->FreeMemory(pText);

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Wmiutils.h

Library

Wbemuuid.lib

DLL

Wmiutils.dll

See also

IWbemQuery
SWbemAssocQueryInf
SWbemRpnEncodedQuery

 

 

Show:
© 2015 Microsoft