Windows Dev Center

SensorAdapterQueryStatus function

Called by the Windows Biometric Framework to retrieve information about the current status of the sensor device.

Syntax


HRESULT WINAPI SensorAdapterQueryStatus(
  _Inout_ PWINBIO_PIPELINE      Pipeline,
  _Out_   PWINBIO_SENSOR_STATUS Status
);

Parameters

Pipeline [in, out]

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

Status [out]

Pointer to a WINBIO_SENSOR_STATUS value that receives the status information.

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 SensorContext member of the WINBIO_PIPELINE structure pointed to by the Pipeline argument is NULL or the SensorHandle member is set to INVALID_HANDLE_VALUE.

 

Examples

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


//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterQueryStatus
//
// Purpose:
//      Retrieves information about the current status of the sensor device.
//      
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit.
//      Status   -  Pointer to a WINBIO_SENSOR_STATUS value that receives 
//                  the status information.
//
static HRESULT
WINAPI
SensorAdapterQueryStatus(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PWINBIO_SENSOR_STATUS Status
    )
{
    HRESULT hr = S_OK;
    WINBIO_SENSOR_STATUS sensorStatus = WINBIO_SENSOR_FAILURE;
    BOOL result = TRUE;
    DWORD bytesReturned = 0;

    // Verify that the pointer parameters are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(Status))
    {
        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 || 
        Pipeline->SensorHandle == INVALID_HANDLE_VALUE)
    {
        return WINBIO_E_INVALID_DEVICE_STATE;
    }

    // This sample assumes that the sensor driver returns
    // a fixed-size WINBIO_SENSOR_STATUS buffer in response
    // to a vendor-defined query IOCTL.
    result = DeviceIoControl(
                Pipeline->SensorHandle,
                IOCTL_VENDOR_PRIVATE_CMD_QUERY_STATUS,
                NULL,
                0,
                &sensorStatus,
                sizeof(WINBIO_SENSOR_STATUS),
                &bytesReturned,
                &sensorContext->Overlapped
                );
    if (!result && GetLastError() == ERROR_IO_PENDING)
    {
        SetLastError(ERROR_SUCCESS);

        result = GetOverlappedResult(
                    Pipeline->SensorHandle,
                    &sensorContext->Overlapped,
                    &bytesReturned,
                    TRUE
                    );
    }
    if (!result || bytesReturned < sizeof(WINBIO_SENSOR_STATUS))
    {
        hr = _AdapterGetHresultFromWin32(GetLastError());
    }
    else
    {
        *Status = sensorStatus;
    }
    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

 

 

Community Additions

ADD
Show:
© 2015 Microsoft