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

 

HRESULT ExecNotificationQueryAsync(

[in]  const BSTR strQueryLanguage,

[in]  const BSTR strQuery,

[in]  long lFlags,

[in]  IWbemContext *pCtx,

[in]  IWbemObjectSink *pResponseHandler

);

 

PowerBASIC Syntax

 

METHOD ExecNotificationQueryAsync ( _

BYVAL strQueryLanguage AS DWORD, _

BYVAL strQuery AS DWORD, _

BYVAL lFlags AS LONG, _

BYVAL pCtx AS IWbemContext, _

BYVAL pResponseHandler AS IWbemObjectSink _

) AS LONG

 

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.

 

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

 

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.

 

Return code

Description

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

An invalid parameter was specified.

WBEM_E_REGISTRATION_TOO_PRECISE

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

WBEM_E_REGISTRATION_TOO_BROAD

The query requests more information than Windows Management 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.

 

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

 

Client

Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0 SP4 and later, Windows Me, Windows 98, or Windows 95.

Server

Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later.

Header

Declared in Wbemcli.h; include Wbemidl.h.

Library

Use Wbemuuid.lib.

DLL

Requires Fastprox.dll.

Requires Esscli.dll.

Requires Framedyn.dll.

Requires Ntevt.dll.

Requires Stdprov.dll.

Requires Viewprov.dll.

Requires Wbemcomn.dll.

Requires Wbemcore.dll.

Requires Wbemess.dll.

Requires Wbemsvc.dll.

Requires Wmipicmp.dll.

Requires Wmidcprv.dll.

Requires Wmipjobj.dll.

Requires Wmiprvsd.dll.

 

Valid XHTML 1.0 Transitional