PIBIO_ENGINE_DETACH_FN回呼函式 (winbio_adapter.h)

在從生物特徵辨識單位的處理管線中移除引擎配接器之前,立即由 Windows 生物特徵辨識架構呼叫。 此函式的目的是要釋放附加至管線的配接器特定資源。

語法

PIBIO_ENGINE_DETACH_FN PibioEngineDetachFn;

HRESULT PibioEngineDetachFn(
  [in, out] PWINBIO_PIPELINE Pipeline
)
{...}

參數

[in, out] Pipeline

與執行作業之生物特徵辨識單位相關聯的 WINBIO_PIPELINE 結構的指標。

傳回值

如果函式成功,則會傳回S_OK。 如果函式失敗,它必須傳回下列其中一個 HRESULT 值,以指出錯誤。

傳回碼 Description
E_POINTER
Pipeline 參數不可為 NULL
WINBIO_E_INVALID_DEVICE_STATE
WINBIO_PIPELINE 結構的 EngineContext 字段不可為 NULL

備註

若要防止記憶體流失,您的 EngineAdapterDetach 函式實作必須釋放管線之 EngineContext 成員所指向的私人WINBIO_ENGINE_CONTEXT結構,以及附加至引擎內容的任何其他資源。

如果在呼叫此函式時,管線物件中的 EngineContext 字段為 NULL ,則管線未正確初始化,而且您必須傳回 WINBIO_E_INVALID_DEVICE_STATE ,以通知 Windows 生物特徵辨識架構發生問題。

傳回S_OK之前,EngineAdapterDetach 函式必須將WINBIO_PIPELINE結構的 EngineContext 字段設定為 NULL,並將 EngineHandle 字段設定為 INVALID_HANDLE_VALUE

從管線中移除存儲設備配接器之後,就會呼叫此函式。 因此,此函式不得呼叫管線物件的 StorageInterface 成員所指向之 WINBIO_STORAGE_INTERFACE 結構所參考的任何函式。

範例

下列虛擬程式代碼顯示此函式的一個可能實作。 此範例不會編譯。 您必須調整它以符合您的用途。

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterDetach
//
// Purpose:
//      Releases adapter specific resources attached to the pipeline.
//      
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit.
//
static HRESULT
WINAPI
EngineAdapterDetach(
    __inout PWINBIO_PIPELINE Pipeline
    )
{
    PWINBIO_ENGINE_CONTEXT context = NULL;

    // Verify that the Pipeline parameter is not NULL.
    if (!ARGUMENT_PRESENT(Pipeline))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline and assign it to a local
    // variable.
    context = (PWINBIO_ENGINE_CONTEXT)Pipeline->EngineContext;
    if (context == NULL)
    {
        goto cleanup;
    }

    // Set the context on the pipeline to NULL.
    Pipeline->EngineContext = NULL;

    // If your adapter supports software-based template hashing and you
    // opened a Cryptography Next Generation (CNG) hash object handle
    // during initialization, implement the following custom function to 
    // release the CNG resources.
    _AdapterCleanupCrypto(context);

    // Implement one or more custom routines to release any structures 
    // that remain attached to the context block. These structures can 
    // include the most recent feature set, the current enrollment template, 
    // and other custom defined objects.
    if (context->FeatureSet != NULL)
    {
        _AdapterRelease(context->FeatureSet);
        context->FeatureSet = NULL;
        context->FeatureSetSize = 0;
    }

    if (context->Enrollment.Template != NULL)
    {
        _AdapterRelease(context->Enrollment.Template);
        context->Enrollment.Template = NULL;
        context->Enrollment.TemplateSize = 0;
        context->Enrollment.SampleCount = 0;
    }

    if (context->SomePointerField != NULL)
    {
        _AdapterRelease(context->SomePointerField);
        context->SomePointerField = NULL;
    }

    // Release the context block.
    _AdapterRelease(context);

cleanup:

    return S_OK;
}

規格需求

需求
最低支援的用戶端 Windows 7 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 R2 [僅限桌面應用程式]
目標平台 Windows
標頭 winbio_adapter.h (包含 Winbio_adapter.h)

另請參閱

EngineAdapterAttach

外掛程式函式

SensorAdapterDetach