Export (0) Print
Expand All

IWbemServices::ExecNotificationQueryAsync method

The IWbemServices::ExecNotificationQueryAsync method performs the same task as IWbemServices::ExecNotificationQuery except that events are supplied to the specified response handler until CancelAsyncCall is called to stop the event notification.

Syntax


HRESULT ExecNotificationQueryAsync(
  [in]  const BSTR strQueryLanguage,
  [in]  const BSTR strQuery,
  [in]  long lFlags,
  [in]  IWbemContext *pCtx,
  [in]  IWbemObjectSink *pResponseHandler
);

Parameters

strQueryLanguage [in]

Valid BSTR that contains one of the query languages supported by Windows Management. This must be "WQL".

strQuery [in]

Valid BSTR that contains the text of the event-related query. This cannot be NULL. For more information on building WMI query strings, see Querying with WQL and the WQL reference.

lFlags [in]

This parameter can be the following value.

FlagMeaning
WBEM_FLAG_SEND_STATUS

This flag registers with Windows Management a request to receive intermediate status reports through the client's implementation of IWbemObjectSink::SetStatus. Provider implementation must support intermediate status reporting for this flag to change behavior.

 

pCtx [in]

Typically NULL. Otherwise, this is a pointer to an IWbemContext object that may be used by the provider that is returning the requested events. The values in the context object must be specified in the documentation for the provider in question. For more information about this parameter, see Making Calls to WMI.

pResponseHandler [in]

Pointer to the caller's implementation of IWbemObjectSink. This handler receives the objects in the query result set as they become available. To cease receiving events, the caller must call IWbemServices::CancelAsyncCall using the same pointer value for pResponseHandler. As events become available, the supplied IWbemObjectSink::Indicate implementation is called to deliver the event objects. The IWbemObjectSink::SetStatus method is not called at any time, because there is no final or terminating condition. The call executes indefinitely until canceled. If any error code is returned, then the supplied IWbemObjectSink pointer is not used. If WBEM_S_NO_ERROR is returned, then the user's IWbemObjectSink implementation is called to indicate the result of the operation. Windows Management only calls AddRef on the pointer in cases where WBEM_S_NO_ERROR returns. In cases where an error code returns, the reference count is the same as on entry. For a detailed explanation of this parameter, see Calling a Method.

Return value

This method returns an HRESULT indicating the status of the method call. The following table lists the value contained within an HRESULT.

On failure, you can obtain any available information from the COM function GetErrorInfo.

Other error codes are returned to the object sink specified by the pResponseHandler parameter.

COM-specific error codes also can be returned if network problems cause you to lose the remote connection to Windows Management.

Return codeDescription
WBEM_E_FAILED

This indicates other unspecified errors.

WBEM_E_INVALID_CLASS

The query specifies a class that does not exist.

WBEM_E_INVALID_PARAMETER

A specified parameter is not valid.

WBEM_E_REGISTRATION_TOO_PRECISE

Too much precision in delivery of events has been requested. A larger polling tolerance should be specified.

WBEM_E_REGISTRATION_TOO_BROAD

The query requests more information than WMI can reasonably provide. This message is returned when an event query results in a request to poll all objects in a namespace.

WBEM_E_INVALID_QUERY

The query was not syntactically valid.

WBEM_E_INVALID_QUERY_TYPE

The requested query language is not supported.

WBEM_E_OUT_OF_MEMORY

There was not enough memory to complete the operation.

WBEM_E_SHUTTING_DOWN

Windows Management service was stopped and restarted. A new call to ConnectServer is required.

WBEM_E_TRANSPORT_FAILURE

This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management.

WBEM_E_UNPARSABLE_QUERY

The query cannot be parsed.

WBEM_S_NO_ERROR

The call succeeded.

 

Remarks

The IWbemObjectSink::SetStatus method is called to indicate the end of the result set. It may also be called with no intervening calls to IWbemObjectSink::Indicate if error conditions occur.

Because the call-back might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. If you require asynchronous communication, see Calling a Method.

For more information about using methods semisynchronously, see IWbemServices::ExecNotificationQuery and Calling a Method.

There are limits to the number of AND and OR keywords that can be used in WQL queries. Large numbers of WQL keywords used in a complex query can cause WMI to return the WBEM_E_QUOTA_VIOLATION error code as an HRESULT value. The limit of WQL keywords depends on how complex the query is.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Fastprox.dll;
Esscli.dll;
Framedyn.dll;
Ntevt.dll;
Stdprov.dll;
Viewprov.dll;
Wbemcomn.dll;
Wbemcore.dll;
Wbemess.dll;
Wbemsvc.dll;
Wmipicmp.dll;
Wmidcprv.dll;
Wmipjobj.dll;
Wmiprvsd.dll

See also

IWbemServices
Calling a Method
Receiving Event Notifications
Receiving Events for the Duration of your Application
IWbemServices::ExecQuery

 

 

Show:
© 2014 Microsoft