Microsoft指纹SDK C ++ winbio.lib无法正常工作

时间:2013-12-30 09:46:23

标签: c++ visual-studio-2010 winapi fingerprint

我目前正在开发指纹验证项目,并且我已经正确配置了所有驱动程序。我正在使用Microsoft指纹识别器,当我在登录期间使用DigitalPersona软件进行测试时,它可以正常工作。我目前有Windows sdk 7.0A,我正在使用Microsoft Visual Studio 2010.

我为这段代码创建了一个“空项目”,并且我已将其他库依赖项链接到windows sdk,并在“输入”下键入winbio.lib以获取其他依赖项。我收到了这个错误。

错误C2065:'CaptureSampleCallback':未声明的标识符

这是代码,我完全按照微软的样本但它无法工作=( 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;
}
}

1 个答案:

答案 0 :(得分:1)

您有两种解决方案:

一个。调用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中。在CaptureSampleCallback

之前移动函数CaptureSampleWithCallback的定义