2014-01-24 37 views
0

我有这个错误,我找不到如何解决这个问题。我应该更改哪个参数?我有这个错误。错误C2664:无法转换参数(指纹传感器检测)

error C2664: 'WinBioLocateSensorWithCallback' : cannot convert parameter 2 from 'void (__stdcall *)(void)' to 'PWINBIO_LOCATE_SENSOR_CALLBACK' 

感谢您的帮助!

下面是代码

#include <Windows.h> 
#include <Conio.h> 
#include <Stdio.h> 
#include <WinBio.h> 
VOID CALLBACK LocateSensorCallback(); 

HRESULT LocateSensorWithCallback(BOOL bCancel) 
{ 
    HRESULT hr = S_OK; 
WINBIO_SESSION_HANDLE sessionHandle = NULL; 
WINBIO_UNIT_ID unitId = 0; 

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

wprintf_s(L"\n Calling WinBioLocateSensorWithCallback."); 
hr = WinBioLocateSensorWithCallback(
      sessionHandle,   // Open biometric session 
      LocateSensorCallback, // Callback function 
      NULL     // Optional context 
      ); 
if (FAILED(hr)) 
{ 
    wprintf_s(L"\n WinBioLocateSensorWithCallback failed."); 
    wprintf_s(L"hr = 0x%x\n", hr); 
    goto e_Exit; 
} 
wprintf_s(L"\n Swipe the sensor ...\n"); 

// Cancel the identification if the bCancel flag is set. 
if (bCancel) 
{ 
    wprintf_s(L"\n Starting CANCEL timer...\n"); 
    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 identification 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) 
{ 
    wprintf_s(L"\n Closing the session.\n"); 

    hr = WinBioCloseSession(sessionHandle); 
    if (FAILED(hr)) 
    { 
     wprintf_s(L"\n WinBioCloseSession failed. hr = 0x%x\n", hr); 
    } 
    sessionHandle = NULL; 
} 

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

return hr; 
} 

//------------------------------------------------------------------------ 
// The following function is the callback for 
// WinBioLocateSensorWithCallback. The function filters the response 
// from the biometric subsystem and writes a result to the console window. 
// 
VOID CALLBACK LocateSensorCallback(
__in_opt PVOID LocateCallbackContext, 
__in HRESULT OperationStatus, 
__in WINBIO_UNIT_ID UnitId 
) 
{ 
UNREFERENCED_PARAMETER(LocateCallbackContext); 

wprintf_s(L"\n LocateSensorCallback executing."); 

// A sensor could not be located. 
if (FAILED(OperationStatus)) 
{ 
    wprintf_s(L"\n LocateSensorCallback failed."); 
    wprintf_s(L"OperationStatus = 0x%x\n", OperationStatus); 
} 
// A sensor was located. 
else 
{ 
    wprintf_s(L"\n Selected unit ID: %d\n", UnitId); 
} 
} 



void main() 

{ 
LocateSensorWithCallback(1); 
} 

回答

0

你的问题是,你的LocateSensorCallback定义不匹配的签名,该WinBioLocateSensorWithCallback功能的期望。

顶部从

VOID CALLBACK LocateSensorCallback(); 

更改您的声明符合实际的功能:

VOID CALLBACK LocateSensorCallback(
__in_opt PVOID LocateCallbackContext, 
__in HRESULT OperationStatus, 
__in WINBIO_UNIT_ID UnitId 
); 
+0

这解决了它!非常感谢你!!! = d – victorteoh90

相关问题