共用方式為


PIBIO_ENGINE_ATTACH_FN回呼函式 (winbio_adapter.h)

當引擎配接器新增至生物特徵辨識單位的處理管線時,由 Windows 生物特徵辨識架構呼叫。 此函式的目的是要執行後續生物特徵辨識作業所需的任何初始化。

語法

PIBIO_ENGINE_ATTACH_FN PibioEngineAttachFn;

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

參數

[in, out] Pipeline

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

傳回值

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

傳回碼 描述
E_POINTER
Pipeline引數不可為Null
E_OUTOFMEMORY
作業因為記憶體不足而無法完成。
WINBIO_E_INVALID_DEVICE_STATE
Pipeline引數所指向之WINBIO_PIPELINE結構的EngineCoNtext成員不是Null,或者EngineHandle成員未設定為INVALID_HANDLE_VALUE

備註

在儲存體配接器初始化生物特徵辨識單位之前,會呼叫此函式。 因此,此函式不得呼叫管線物件的StorageInterface成員所指向之WINBIO_STORAGE_INTERFACE結構所參考的任何函式。

實作此函式時,您必須配置和管理介面卡所需的任何資源,並將這些資源附加至生物特徵辨識單元管線。 若要這樣做,請在堆積上配置私人 WINBIO_ENGINE_CONTEXT 結構、初始化它,並在管線物件的 EngineCoNtext 成員中設定其位址。

如果在建立和初始化此函式所使用的引擎配接器資源期間發生錯誤,您必須先執行任何必要的清除,才能傳回。

如果呼叫此函式時 EngineCoNtext 欄位不是 Null ,則管線未正確初始化,而且您必須傳回 WINBIO_E_INVALID_DEVICE_STATE 通知 Windows 生物特徵辨識架構的問題。

同樣地,如果呼叫此函式時 ,EngineHandle 欄位不包含 INVALID_HANDLE_VALUE ,您必須傳回 WINBIO_E_INVALID_DEVICE_STATE

範例

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

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterAttach
//
// Purpose:
//      Performs any initialization required for later biometric operations.
//
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit performing the operation.
//
static HRESULT
WINAPI
EngineAdapterAttach(
    __inout PWINBIO_PIPELINE Pipeline
    )
{
    HRESULT hr = S_OK;

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

    // Retrieve the context from the pipeline.
    PWINBIO_ENGINE_CONTEXT newContext = NULL;

    // Call a custom function (_AdapterAlloc) to allocate memory to hold the 
    // engine adapter context.
    newContext = (PWINBIO_ENGINE_CONTEXT)_AdapterAlloc(sizeof(WINBIO_ENGINE_CONTEXT));
    if (newContext == NULL)
    {
        E_OUTOFMEMORY;
        goto cleanup;
    }

    // Clear the context memory.
    ZeroMemory(newContext, sizeof(WINBIO_ENGINE_CONTEXT));

    // Initialize any required context fields.
    newContext->SomeField = SomeSpecialValue;

    newContext->SomePointerField = _AdapterAlloc(sizeof(SOME_STRUCTURE));
    if (newContext->SomePointerField == NULL)
    {
        E_OUTOFMEMORY;
        goto cleanup;
    }

    // If your adapter supports software-based template hashing, implement the 
    // following custom function to open a SHA1 hash object handle and store 
    // the handle in the adapter context. Use Cryptography Next Generation (CNG) 
    // functions to create the SHA1 hash object.
    hr = _AdapterInitializeCrypto(newContext);
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // If initialization completes successfully, attach the engine context to the 
    // processing pipeline of the biometric unit.
    Pipeline->EngineContext = newContext;
    newContext = NULL;

cleanup:
    if (FAILED(hr))
    {
        // If a new context has been created, release any memory 
        // pointed to by various data members in the context and 
        // then release the context. The following example assumes 
        // that your adapter contains a handle
        // for a hash object and a pointer to another object.
        if (newContext != NULL)
        {
            // Close any open CNG handles and release the hash object memory.
            _AdapterCleanupCrypto(newContext);

            // Release any other object pointed to by the context.
            if (newContext->SomePointerField != NULL)
            {
                _AdapterRelease(newContext->SomePointerField);
            }

            // Release the context
            _AdapterRelease(newContext);
        }
    }
    return hr;

}

規格需求

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

另請參閱

EngineAdapterDetach

外掛程式函式

SensorAdapterAttach

StorageAdapterAttach

WINBIO_PIPELINE