PIBIO_STORAGE_DETACH_FN回呼函式 (winbio_adapter.h)

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

語法

PIBIO_STORAGE_DETACH_FN PibioStorageDetachFn;

HRESULT PibioStorageDetachFn(
  [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 結構的 StorageContext 字段不可為 NULL

備註

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

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

傳回S_OK之前,此函式必須將 WINBIO_PIPELINE 結構的 StorageContext 字段設定為 NULL,並將 StorageHandle 字段設定為 INVALID_HANDLE_VALUE

範例

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

/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterDetach
//
// Purpose:
//      Release adapter specific resources attached to the pipeline.
//
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit performing the operation.
//
static HRESULT
WINAPI
StorageAdapterDetach(
    __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_STORAGE_CONTEXT storageContext = 
           (PWINBIO_STORAGE_CONTEXT)Pipeline->StorageContext;

    // Verify the pipeline state.
    if (storageContext == NULL)
    {
        // The pipeline state is not valid. This function should never
        // be called if the storage context in the pipeline is already
        // closed.
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Release any structures attached to the context block.
    StorageAdapterClearContext(Pipeline);

    // Close the database.
    StorageAdapterCloseDatabase(Pipeline);

    // Remove the context from the pipeline.
    Pipeline->StorageContext = NULL;
    Pipeline->StorageHandle = INVALID_HANDLE_VALUE;

    // Clear the result set. Depending on your implementation, this action
    // can be performed by the StorageAdapterClearContext function called
    // earlier.
    ResultSetCleanup(&storageContext->ResultSet);

    // Release the adapter context.
    _AdapterRelease( storageContext );
    storageContext = NULL;

cleanup:

    return hr;
}

規格需求

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

另請參閱

外掛程式函式

StorageAdapterAttach