IWMSEventNotificationPlugin::GetHandledEvents

banner art

Previous Next

IWMSEventNotificationPlugin::GetHandledEvents

The server calls the GetHandledEvents method to retrieve an array containing the events that can be handled by the plug-in.

Syntax

  HRESULT GetHandledEvents(
  VARIANT*  pvarEvents
);

Parameters

pvarEvents

[out] Pointer to a VARIANT containing a SAFEARRAY of WMS_EVENT_TYPE enumeration values.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.

Example Code

The following example illustrates a possible implementation of the GetHandledEvents method for a logging plug-in.

STDMETHODIMP 
CLoggingEventPlugin::GetHandledEvents( VARIANT * pvarEvents )
{
    HRESULT hr = S_OK;

    // Specify events the plug-in can handle.
    WMS_EVENT_TYPE wmsEvents[ 2 ] = { WMS_EVENT_PUBLISHING_POINT,
                                      WMS_EVENT_UNKNOWN_EVENT};

    // Set up the safearray boundaries and create the array.
    rgsabound[0].lLbound = 0;
    nNumEvents = sizeof( wmsEvents ) / sizeof( WMS_EVENT_TYPE );
    rgsabound[0].cElements = nNumEvents;

    psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );

    // Add each of the events to the safearray.
    for( iEvents = 0; iEvents < nNumEvents && SUCCEEDED(hr); iEvents++ )
    {
        VARIANT varElement;
        VariantInit( &varElement );
        V_VT(&varElement) = VT_I4;
        V_I4(&varElement) = pWMSEvents[iEvents];

        hr = SafeArrayPutElement( psa, &iEvents, &varElement );
        VariantClear( &varElement );
    }

    V_ARRAY(pvarEvents) = psa;

    return ( hr );
}

Requirements

Header: event.h.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Previous Next