Question

I'm currently working on a Fingerprint verification project and I've already configured all the drivers properly. I'm using Microsoft Fingerprint Reader and it works when i tested it with the software DigitalPersona during login. I currently have windows sdk 7.0A and I'm using Microsoft Visual Studio 2010.

I created an "empty project" for this code and I've linked additional library dependencies to the windows sdk and type the winbio.lib under the "input" for additional dependencies. i got this error.

error C2065: 'CaptureSampleCallback' : undeclared identifier

Here's the code, i followed exactly the microsoft's sample but it can't work =( http://msdn.microsoft.com/en-us/library/windows/desktop/dd401603(v=vs.85).aspx

#include <Windows.h>
#include <Conio.h>
#include <Stdio.h>
#include <WinBio.h>


HRESULT CaptureSampleWithCallback(BOOL bCancel)
{

HRESULT hr = S_OK;
WINBIO_SESSION_HANDLE sessionHandle = NULL;

// Connect to the system pool. 
hr = WinBioOpenSession( 
        WINBIO_TYPE_FINGERPRINT,    // Service provider
        WINBIO_POOL_SYSTEM,         // Pool type
        WINBIO_FLAG_RAW,            // Raw access
        NULL,                       // Array of biometric unit IDs
        0,                          // Count of biometric unit IDs
        WINBIO_DB_DEFAULT,          // Default database
        &sessionHandle              // [out] Session handle
        );
if (FAILED(hr))
{
    wprintf_s(L"\n WinBioOpenSession failed. hr = 0x%x\n", hr);
    goto e_Exit;
}

// Capture a biometric sample asynchronously.
wprintf_s(L"\n Calling WinBioCaptureSampleWithCallback ");
hr = WinBioCaptureSampleWithCallback(
        sessionHandle,                  // Open session handle
        WINBIO_NO_PURPOSE_AVAILABLE,    // Intended use of the sample
        WINBIO_DATA_FLAG_RAW,           // Sample format
        CaptureSampleCallback,          // Callback function
        NULL                            // Optional context
        );
if (FAILED(hr))
{
    wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
    wprintf_s(L"hr = 0x%x\n", hr);
    goto e_Exit;
}
wprintf_s(L"\n Swipe the sensor ...\n");

// Cancel the capture process if the bCancel flag is set.
if (bCancel)
{
    wprintf_s(L"\n Starting CANCEL timer...");
    Sleep( 7000 );

    wprintf_s(L"\n Calling WinBioCancel\n");
    hr = WinBioCancel( sessionHandle );
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioCancel failed. hr = 0x%x\n", hr);
        goto e_Exit;
    }
}

// Wait for the asynchronous capture process to complete 
// or be canceled.
hr = WinBioWait( sessionHandle );
if (FAILED(hr))
{
    wprintf_s(L"\n WinBioWait failed. hr = 0x%x\n", hr);
}


e_Exit:

if (sessionHandle != NULL)
{
    WinBioCloseSession(sessionHandle);
    sessionHandle = NULL;
}

wprintf_s(L"\n Press any key to exit...");
_getch();

return hr;
}

//------------------------------------------------------------------------
// The following function is the callback for WinBioCaptureSampleWithCallback.
// The function filters the response from the biometric subsystem and 
// writes a result to the console window.
//
VOID CALLBACK CaptureSampleCallback(
__in_opt PVOID CaptureCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_UNIT_ID UnitId,
__in_bcount(SampleSize) PWINBIO_BIR Sample,
__in SIZE_T SampleSize,
__in WINBIO_REJECT_DETAIL RejectDetail
)
{
UNREFERENCED_PARAMETER(CaptureCallbackContext);

wprintf_s(L"\n CaptureSampleCallback executing");
wprintf_s(L"\n Swipe processed - Unit ID: %d", UnitId);

if (FAILED(OperationStatus))
{
    if (OperationStatus == WINBIO_E_BAD_CAPTURE)
    {
        wprintf_s(L"\n Bad capture; reason: %d\n", RejectDetail);
     }
    else
    {
        wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
        wprintf_s(L" OperationStatus = 0x%x\n", OperationStatus);
    }
    goto e_Exit;
}

wprintf_s(L"\n Captured %d bytes.\n", SampleSize);

e_Exit:

if (Sample != NULL)
{
    WinBioFree(Sample);
    Sample = NULL;
}
}
Was it helpful?

Solution

You have two solutions:

A. function prototype before calling CaptureSampleCallback

VOID CALLBACK CaptureSampleCallback(
__in_opt PVOID CaptureCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_UNIT_ID UnitId,
__in_bcount(SampleSize) PWINBIO_BIR Sample,
__in SIZE_T SampleSize,
__in WINBIO_REJECT_DETAIL RejectDetail
);

B. Move definition of function CaptureSampleCallback before CaptureSampleWithCallback

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top