Freigeben über


Initializing and Binding a Pipeline Module

Pipeline modules must create and bind to a pipeline module connector when their IFsrmPipelineModuleImplementation::OnLoad implementation is called. This can be done as the last step of any module initialization that is performed in the function.

The following example shows how to create and bind to a pipeline module connector:

#include <windows.h>
#include <stdio.h>
#include <comutil.h>
#include <atlbase.h>
#include <atlcom.h>
#include <FsrmQuota.h>  // quota objects
#include <FsrmTlb.h>    // Contains CLSIDs.
// <...>
STDMETHODIMP CCustomModule::OnLoad(
    IFsrmPipelineModuleDefinition   *pDefinition,
    IFsrmPipelineModuleConnector    **ppModuleConnector
    )
{
    HRESULT hr = S_OK;

    //
    //  ...perform module initialization...
    //

    //  Create the connector
    CComPtr<IFsrmPipelineModuleConnector> spConnector;
    hr = CoCreateInstance(CLSID_FsrmPipelineModuleConnector,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          __uuidof(IFsrmPipelineModuleConnector),
                          (LPVOID *)&amp;spConnector);
    if (FAILED(hr))
    {
        ATLTRACE(L"CoCreateInstance(FsrmPipelineModuleConnector) failed, 0x%x.\n", hr);
        goto cleanup;
    }

    CComQIPtr<IFsrmPipelineModuleImplementation> spModuleImpl = GetControllingUnknown();
    if (spModuleImpl == NULL)
    {
        ATLTRACE(L"GetControllingUnknown failed.\n");
        hr = E_OUTOFMEMORY;
        goto cleanup;
    }

    //  Bind the connector to the module
    hr = spConnector->Bind(pDefinition, spModuleImpl);
    if (FAILED(hr))
    {
        ATLTRACE(L"spConnector->Bind failed, 0x%x.\n", hr);
        goto cleanup;
    }

    //  Return the connector
    *ppModuleConnector = spConnector.Detach();

cleanup:

    return hr;
}