função de retorno de chamada PIBIO_SENSOR_EXPORT_SENSOR_DATA_FN (winbio_adapter.h)

Chamado pela Estrutura Biométrica do Windows para recuperar uma cópia da amostra biométrica capturada mais recentemente formatada como uma estrutura de WINBIO_BIR padrão.

Sintaxe

PIBIO_SENSOR_EXPORT_SENSOR_DATA_FN PibioSensorExportSensorDataFn;

HRESULT PibioSensorExportSensorDataFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PWINBIO_BIR *SampleBuffer,
  [out]     PSIZE_T SampleSize
)
{...}

Parâmetros

[in, out] Pipeline

Ponteiro para a estrutura de WINBIO_PIPELINE associada à unidade biométrica que executa a operação.

[out] SampleBuffer

Endereço de uma variável que recebe um ponteiro para uma estrutura WINBIO_BIR que contém o exemplo.

[out] SampleSize

Ponteiro para uma variável que recebe o tamanho, em bytes, do buffer especificado pelo parâmetro SampleBuffer .

Valor retornado

Se a função for bem-sucedida, ela retornará S_OK. Se a função falhar, ela deverá retornar um dos seguintes valores HRESULT para indicar o erro.

Código de retorno Descrição
E_OUTOFMEMORY
Não há memória suficiente disponível para criar a estrutura WINBIO_BIR .
E_POINTER
Um parâmetro de ponteiro obrigatório é NULL.
WINBIO_E_INVALID_DEVICE_STATE
O membro SensorContext da estrutura WINBIO_PIPELINE apontada pelo argumento Pipeline é NULL.
WINBIO_E_NO_CAPTURE_DATA
Nenhum dado de captura existe.
E_NOTIMPL
No momento, esse método não está implementado.

Comentários

Você deve alocar o buffer a ser retornado no parâmetro SampleBuffer do heap de processo usando a função HeapAlloc . Depois de criado, esse buffer se torna a propriedade da Estrutura Biométrica do Windows. Como o Framework desaloca essa memória quando termina de usá-la, sua implementação dessa função não deve tentar desalocar o buffer nem salvar um ponteiro para ela. Ao não salvar o ponteiro, você impede que outras partes do adaptador do mecanismo tentem usar o buffer depois que essa função retornar.

Exemplos

O pseudocódigo a seguir mostra uma possível implementação dessa função. O exemplo não é compilado. Você deve adaptá-lo para se adequar à sua finalidade.

//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterExportSensorData
//
// Purpose:
//      Retrieves a copy of the most recently captured biometric sample.
//      
// Parameters:
//      Pipeline     -  Pointer to a WINBIO_PIPELINE structure associated with 
//                      the biometric unit.
//      SampleBuffer -  Address of a variable that receives a pointer to a 
//                      WINBIO_BIR structure that contains the sample.
//      SampleSize   -  Pointer to a variable that receives the size, in bytes, 
//                      of the buffer specified by the SampleBuffer parameter.
//
static HRESULT
WINAPI
SensorAdapterExportSensorData(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PWINBIO_BIR *SampleBuffer,
    __out SIZE_T *SampleSize
    )
{
    PWINBIO_BIR sampleBuffer = NULL;

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(SampleBuffer) ||
        !ARGUMENT_PRESENT(SampleSize))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline.
    PWINBIO_SENSOR_CONTEXT sensorContext = 
                 (PWINBIO_SENSOR_CONTEXT)Pipeline->SensorContext;

    // Verify the state of the pipeline.
    if (sensorContext == NULL)
    {
        return WINBIO_E_INVALID_DEVICE_STATE;
    }

    // Determine whether there is capture data to return.
    if (sensorContext->CaptureBuffer == NULL ||
        sensorContext->CaptureBuffer->CaptureData.Size == 0)
    {
        return WINBIO_E_NO_CAPTURE_DATA;
    }

    // Allocate a buffer, copy the data into it, and return
    // the buffer and buffer size to the caller.
    sampleBuffer = _AdapterAlloc(sensorContext->CaptureBuffer->CaptureData.Size);
    if (sampleBuffer == NULL)
    {
        return E_OUTOFMEMORY;
    }
    RtlCopyMemory(
        sampleBuffer, 
        sensorContext->CaptureBuffer->CaptureData.Data,
        sensorContext->CaptureBuffer->CaptureData.Size
        );

    *SampleBuffer = sampleBuffer;
    sampleBuffer = NULL;

    *SampleSize = Pipeline->SensorContext->CaptureBuffer->CaptureData.Size;  

    return S_OK;
}

Requisitos

   
Cliente mínimo com suporte Windows 7 [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows Server 2008 R2 [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho winbio_adapter.h (inclua Winbio_adapter.h)

Confira também

Funções de plug-in