IFunctionDiscoveryNotification::OnUpdate method (functiondiscoveryapi.h)

[Function Discovery is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

Indicates that a function instance has been added, removed, or changed. This method is implemented by the client program and is called by Function Discovery.

Syntax

HRESULT OnUpdate(
  [in] QueryUpdateAction enumQueryUpdateAction,
  [in] FDQUERYCONTEXT    fdqcQueryContext,
  [in] IFunctionInstance *pIFunctionInstance
);

Parameters

[in] enumQueryUpdateAction

A QueryUpdateAction value that specifies the type of action Function Discovery is performing on the specified function instance.

[in] fdqcQueryContext

The context registered for change notification. The type FDQUERYCONTEXT is defined as a DWORDLONG. This parameter can be NULL.

[in] pIFunctionInstance

An IFunctionInstance interface pointer that represents the function instance being affected by the update.

Return value

The client program's implementation of the OnUpdate method should return one of the following HRESULT values to the caller.

Return code Description
S_OK
The method completed successfully.
E_INVALIDARG
The value of one of the input parameters is invalid.

Remarks

Do not call Release on the query object from this method. Doing so could cause a deadlock. If Release is called on a query object from another thread while a callback is in process, the object will not be released until the callback has finished.

All notifications passed to Function Discovery by providers are queued and returned to the client one by one. Callbacks are synchronized so that a client will only receive one notification at a time.

Because other IFunctionDiscoveryNotification method calls may be made in other threads, any changes made to the thread state during the call must be restored before exiting the method.

Examples

The following code shows an OnUpdate handler implementation. The CMyNotificationListener class is defined in the IFunctionDiscoveryNotification topic.

#include <windows.h>

HRESULT STDMETHODCALLTYPE CMyNotificationListener::OnUpdate(
                                          IN QueryUpdateAction Action,
                                          IN FDQUERYCONTEXT fdqcQueryContext,
                                          IN IFunctionInstance *pInstance)
{
    HRESULT hr = S_OK;

    switch (Action) {
    case QUA_ADD:
        SetEvent( m_hAddEvent );
        break;
    case QUA_REMOVE:
        SetEvent( m_hRemoveEvent );
        break;
    case QUA_CHANGE:
        SetEvent( m_hChangeEvent );
        break;
    }
    return S_OK;
}

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header functiondiscoveryapi.h

See also

IFunctionDiscoveryNotification