Share via


PIBIO_STORAGE_ATTACH_FN función de devolución de llamada (winbio_adapter.h)

Lo llama El marco biométrico de Windows cuando se agrega un adaptador de almacenamiento a la canalización de procesamiento de la unidad biométrica. El propósito de esta función es realizar cualquier inicialización necesaria para las operaciones biométricas posteriores.

Sintaxis

PIBIO_STORAGE_ATTACH_FN PibioStorageAttachFn;

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

Parámetros

[in, out] Pipeline

Puntero a una estructura de WINBIO_PIPELINE asociada a la unidad biométrica que realiza la operación.

Valor devuelto

Si la función se ejecuta correctamente, devuelve S_OK. Si se produce un error en la función, debe devolver uno de los siguientes valores HRESULT para indicar el error.

Código devuelto Descripción
E_POINTER
El argumento Pipeline no puede ser NULL.
E_OUTOFMEMORY
No se pudo completar la operación debido a memoria insuficiente.
WINBIO_E_INVALID_DEVICE_STATE
El miembro StorageContext de la estructura WINBIO_PIPELINE a la que apunta el argumento Pipeline no es NULL o el miembro StorageHandle no está establecido en INVALID_HANDLE_VALUE.

Comentarios

Al implementar esta función, debe asignar y administrar los recursos requeridos por el adaptador y adjuntarlos a la canalización de unidades biométricas. Para ello, asigne una estructura de WINIBIO_STORAGE_CONTEXT privada en el montón, inicialícela y establezca su dirección en el miembro StorageContext del objeto de canalización.

Si el campo StorageContext no es NULL cuando se llama a esta función, la canalización no se restableció correctamente mediante una llamada anterior a StorageAdapterDetach y debe devolver WINBIO_E_INVALID_DEVICE_STATE para notificar al marco biométrico de Windows el problema.

Del mismo modo, si el campo StorageHandle no contiene INVALID_HANDLE_VALUE cuando se llama a esta función, debe devolver WINBIO_E_INVALID_DEVICE_STATE.

Si se produce un error durante la creación e inicialización de los recursos del adaptador de almacenamiento usados por esta función, debe realizar cualquier limpieza necesaria antes de devolverla.

Ejemplos

El siguiente pseudocódigo muestra una posible implementación de esta función. El ejemplo no se compila. Debes adaptarlo para que se adapte a tu propósito.

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

Requisitos

Requisito Value
Cliente mínimo compatible Windows 7 [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows Server 2008 R2 [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado winbio_adapter.h (incluya Winbio_adapter.h)

Consulte también

Funciones de complemento

StorageAdapterDetach