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.
- lFlags [in]
-
This parameter can be the following value.
Flag Meaning - 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 code | Description |
|---|---|
|
This indicates other unspecified errors. |
|
The query specifies a class that does not exist. |
|
A specified parameter is not valid. |
|
Too much precision in delivery of events has been requested. A larger polling tolerance should be specified. |
|
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. |
|
The query was not syntactically valid. |
|
The requested query language is not supported. |
|
There was not enough memory to complete the operation. |
|
Windows Management service was stopped and restarted. A new call to ConnectServer is required. |
|
This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management. |
|
The query cannot be parsed. |
|
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.
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- IWbemServices
- Calling a Method
- Receiving Event Notifications
- Receiving Events for the Duration of your Application
- IWbemServices::ExecQuery
Send comments about this topic to Microsoft
Build date: 11/19/2012