PIBIO_STORAGE_ATTACH_FN回呼函式 (winbio_adapter.h)

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

語法

PIBIO_STORAGE_ATTACH_FN PibioStorageAttachFn;

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

參數

[in, out] Pipeline

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

傳回值

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

傳回碼 Description
E_POINTER
Pipeline 自變數不可為 NULL
E_OUTOFMEMORY
作業因為記憶體不足而無法完成。
WINBIO_E_INVALID_DEVICE_STATE
Pipeline 自變數所指向之WINBIO_PIPELINE結構的 StorageContext 成員不是 NULL,或 StorageHandle 成員未設定為 INVALID_HANDLE_VALUE

備註

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

如果呼叫此函式時 StorageContext 字段不是 NULL ,則管線未由先前呼叫 StorageAdapterDetach 正確重設,您必須傳回 WINBIO_E_INVALID_DEVICE_STATE ,以通知 Windows 生物特徵辨識架構的問題。

同樣地,如果呼叫此函式時 StorageHandle 字段不包含 INVALID_HANDLE_VALUE ,您必須傳回 WINBIO_E_INVALID_DEVICE_STATE

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

範例

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

/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterAttach
//
// 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
StorageAdapterAttach(
    __inout PWINBIO_PIPELINE Pipeline
    )
{
    HRESULT hr = S_OK;
    PWINBIO_STORAGE_CONTEXT newContext = NULL;

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

    if (Pipeline->StorageContext != NULL ||
        Pipeline->StorageHandle != INVALID_HANDLE_VALUE)
    { 
        // The pipeline state is not valid. This function should never
        // be called if the pipeline already contains a storage context
        // or a valid storage handle.
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Call a custom function (_AdapterAlloc) to allocate memory to hold the 
    // sensor adapter context.
    newContext = (PWINBIO_STORAGE_CONTEXT)_AdapterAlloc(sizeof(WINBIO_STORAGE_CONTEXT));
    if (newContext == NULL)
    {
        hr = E_OUTOFMEMORY;
        goto cleanup;
    }

    // Call a custom function to initialize the result set to be used by the next 
    // query operation. Initialization typically requires that you clear the result set
    // of any previous query, mark the set as empty, and place the result set cursor
    // in a known state.
    // The result set is attached to the storage context so that it can persist from
    // one storage adapter call to the next.  
    hr = _ResultSetInitialize(&newContext->ResultSet);
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // TODO: Initialize any other required context fields (not shown).


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

cleanup:

    if (FAILED(hr) && newContext != NULL)
    {
        _ResultSetCleanup(&newContext->ResultSet);
        _AdapterRelease( newContext );
        newContext = NULL;
    }
    return hr;
}

規格需求

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

另請參閱

外掛程式函式

StorageAdapterDetach