PIBIO_STORAGE_CLOSE_DATABASE_FN回呼函式 (winbio_adapter.h)

由 Windows 生物特徵辨識架構呼叫,以關閉與管線相關聯的資料庫,並釋放所有相關資源。

語法

PIBIO_STORAGE_CLOSE_DATABASE_FN PibioStorageCloseDatabaseFn;

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

參數

[in, out] Pipeline

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

傳回值

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

傳回碼 Description
E_POINTER
Pipeline 自變數不可為 NULL
WINBIO_E_DATABASE_CANT_CLOSE
未指定的問題導致要求失敗。

備註

Windows 生物特徵辨識架構不會要求特定的快取原則,但如果資料庫維護了記錄的記憶體內部快取,此函式應該會將未寫入的記錄排清至記憶體。

此函式必須使先前資料庫查詢作業所產生的任何結果集失效。

範例

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

/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterCloseDatabase
//
// Purpose:
//      Close the database associated with the pipeline and free all 
//      related resources.
//
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit performing the operation.
//
static HRESULT
WINAPI
StorageAdapterCloseDatabase(
    __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 ||
        Pipeline->StorageHandle == INVALID_HANDLE_VALUE)
    {
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Remove any data structures attached to the context and remove the
    // context from the pipeline.
    _CleanupCryptoContext(&storageContext->CryptoContext);
    StorageAdapterClearContext(Pipeline);

    // Close the database file handle.
    CloseHandle( Pipeline->StorageHandle );
    Pipeline->StorageHandle = INVALID_HANDLE_VALUE;

    // Call a custom function (_PurgeDeletedRecords) to remove deleted records
    // from the database file.
    _PurgeDeletedRecords( 
        &storageContext->DatabaseId, 
        (LPCWSTR)&storageContext->FilePath
        );

    // Overwrite the database ID and path.
    SecureZeroMemory(&storageContext->DatabaseId, sizeof(WINBIO_UUID));
    SecureZeroMemory(storageContext->FilePath, (MAX_PATH+1)*sizeof(WCHAR));

cleanup:

    return hr;
}

規格需求

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

另請參閱

外掛程式函式

StorageAdapterCreateDatabase

StorageAdapterEraseDatabase

StorageAdapterOpenDatabase