ExecNotificationQueryAsync Method |
Description
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.
C++ Syntax
PowerBASIC Syntax
Parameters
strQueryLanguage
Valid BSTR that contains one of the query languages supported by Windows Management. This must be "WQL".
strQuery
Valid BSTR that contains the text of the event-related query. This cannot be NULL.
lFlags
This parameter can be the following value.
pCtx
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.
pResponseHandler
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.
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.
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
|