StorageAdapterGetDatabaseSize function

Called by the Windows Biometric Framework to retrieve the database size and available space.

Syntax


HRESULT WINAPI StorageAdapterGetDatabaseSize(
  _Inout_ PWINBIO_PIPELINE Pipeline,
  _Out_   PSIZE_T          AvailableRecordCount,
  _Out_   PSIZE_T          TotalRecordCount
);

Parameters

Pipeline [in, out]

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

AvailableRecordCount [out]

Pointer to a variable that receives the number of unused record slots in the database.

TotalRecordCount [out]

Pointer to a variable that receives the number of valid records in the database.

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 codeDescription
E_POINTER

A mandatory pointer argument is NULL.

WINBIO_E_INVALID_DEVICE_STATE

The StorageContext member of the pipeline object is NULL.

 

Examples

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


/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterGetDatabaseSize
//
// Purpose:
//      Retrieves the database size and available space.
//
// Parameters:
//      Pipeline             -  Pointer to a WINBIO_PIPELINE structure associated  
//                              with the biometric unit performing the operation.
//      AvailableRecordCount -  Pointer to a variable that receives the number of 
//                              unused record slots in the database.
//      TotalRecordCount     -  Pointer to a variable that receives the number of 
//                              valid records in the database.
//
static HRESULT
WINAPI
StorageAdapterGetDatabaseSize(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PSIZE_T AvailableRecordCount,
    __out PSIZE_T TotalRecordCount
    )
{
    HRESULT hr = S_OK;
    BOOL lockAcquired = FALSE;
    struct _MY_ADAPTER_FILE_HEADER fileHeader = {0};

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(AvailableRecordCount) ||
        !ARGUMENT_PRESENT(TotalRecordCount))
    {
        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;
    }

    // Call a custom function (_LockDatabase) to lock the database for reading.
    hr = _LockDatabase( Pipeline->StorageHandle, FALSE);
    if (FAILED(hr))
    {
        goto cleanup;
    }
    lockAcquired = TRUE;

    // Call a custom function (_ReadFileHeader) to read the header block to 
    // retrieve the current values.
    hr = _ReadFileHeader( Pipeline->StorageHandle, &fileHeader );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Set the return values.
    *AvailableRecordCount = fileHeader.MaxRecordCount - fileHeader.TotalRecordCount;
    *TotalRecordCount = fileHeader.TotalRecordCount - fileHeader.DeletedRecordCount;

cleanup:

    if (lockAcquired == TRUE)
    {
        _UnlockDatabase( Pipeline->StorageHandle);
        lockAcquired = FALSE;
    }

    return hr;
}


Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

Winbio_adapter.h (include Winbio_adapter.h)

See also

Plug-in Functions

 

 

Show: