PIBIO_STORAGE_CLOSE_DATABASE_FN callback function (winbio_adapter.h)

Called by the Windows Biometric Framework to close the database associated with the pipeline and free all related resources.

Syntax

PIBIO_STORAGE_CLOSE_DATABASE_FN PibioStorageCloseDatabaseFn;

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

Parameters

[in, out] Pipeline

Pointer to a WINBIO_PIPELINE structure associated with the biometric unit performing the operation.

Return value

If the function succeeds, it returns S_OK. If the function fails, it must return one of the following HRESULT values to indicate the error.

Return code Description
E_POINTER
The Pipeline argument cannot be NULL.
WINBIO_E_DATABASE_CANT_CLOSE
An unspecified problem has caused the request to fail.

Remarks

The Windows Biometric Framework does not mandate a particular caching policy, but if the database maintains an in-memory cache of records, this function should flush unwritten records to storage.

This function must invalidate any result sets generated by previous database query operations.

Examples

The following pseudocode shows one possible implementation of this function. The example does not compile. You must adapt it to suit your purpose.

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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;
}

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header winbio_adapter.h (include Winbio_adapter.h)

See also

Plug-in Functions

StorageAdapterCreateDatabase

StorageAdapterEraseDatabase

StorageAdapterOpenDatabase