PWINBIO_IDENTIFY_CALLBACK回呼函式 (winbio.h)
Windows 生物識別架構會呼叫 PWINBIO_IDENTIFY_CALLBACK 函式,以從異步 WinBioIdentifyWithCallback 函式傳回結果。 用戶端應用程式必須實作此函式。
- 實作 PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,以在作業完成時接收通知。
- 呼叫 WinBioAsyncOpenSession 函式 。 在 CallbackRoutine 參數中傳遞回呼的位址。 在 NotificationMethod 參數中傳遞WINBIO_ASYNC_NOTIFY_CALLBACK。 擷取異步會話句柄。
- 使用異步會話句柄來呼叫 WinBioIdentify。 作業完成時,Windows 生物特徵辨識架構會以結果配置並初始化 WINBIO_ASYNC_RESULT 結構,並使用結果結構的指標叫用回呼。
- 從回呼實作呼叫 WinBioFree ,以在您完成使用之後釋放 WINBIO_ASYNC_RESULT 結構。
語法
PWINBIO_IDENTIFY_CALLBACK PwinbioIdentifyCallback;
void PwinbioIdentifyCallback(
[in, optional] PVOID IdentifyCallbackContext,
[in] HRESULT OperationStatus,
[in] WINBIO_UNIT_ID UnitId,
[in] WINBIO_IDENTITY *Identity,
[in] WINBIO_BIOMETRIC_SUBTYPE SubFactor,
[in] WINBIO_REJECT_DETAIL RejectDetail
)
{...}
參數
[in, optional] IdentifyCallbackContext
應用程式所定義的緩衝區指標,並傳遞至 WinBioIdentifyWithCallback 函式的 IdentifyCallbackContext 參數。 架構或生物特徵辨識單位不會修改緩衝區。 您的應用程式可以使用數據來協助判斷要執行的動作,或維護生物特徵辨識擷取的其他資訊。
[in] OperationStatus
擷取作業傳回的錯誤碼。
[in] UnitId
生物特徵辨識單位標識碼。
[in] Identity
WINBIO_IDENTITY結構,可接收提供生物特徵辨識樣本之使用者的 GUID 或 SID。
[in] SubFactor
WINBIO_BIOMETRIC_SUBTYPE值,這個值會接收與生物特徵辨識樣本相關聯的子因素。 如需詳細資訊,請參閱<備註>一節。
[in] RejectDetail
若要執行作業,則為失敗的其他資訊。 如需詳細資訊,請參閱<備註>。
傳回值
無
備註
目前,Windows 生物特徵辨識架構僅支持指紋讀取器。 因此,如果作業失敗,並在 WINBIO_REJECT_DETAIL 常數中傳回其他資訊,它會是下列其中一個值:
- WINBIO_FP_TOO_HIGH
- WINBIO_FP_TOO_LOW
- WINBIO_FP_TOO_LEFT
- WINBIO_FP_TOO_RIGHT
- WINBIO_FP_TOO_FAST
- WINBIO_FP_TOO_SLOW
- WINBIO_FP_POOR_QUALITY
- WINBIO_FP_TOO_SKEWED
- WINBIO_FP_TOO_SHORT
- WINBIO_FP_MERGE_FAILURE
範例
下列程式代碼範例會呼叫 WinBioIdentifyWithCallback ,以識別生物特徵辨識掃描中的使用者。 WinBioIdentifyWithCallback 是一種異步函式,可設定生物特徵辨識子系統來處理另一個線程上的生物特徵辨識輸入。 然後,生物特徵辨識子系統的輸出會傳送至名為IdentifyCallback的自定義回呼函式。 連結到Winbio.lib 靜態庫,並包含下列頭檔:
- Windows.h
- Stdio.h
- Conio.h
- Winbio.h
HRESULT IdentifyWithCallback(BOOL bCancel)
{
// Declare variables.
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_DEFAULT, // Configuration and access
NULL, // Array of biometric unit IDs
0, // Count of biometric unit IDs
WINBIO_DB_DEFAULT, // Database ID
&sessionHandle // [out] Session handle
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioOpenSession failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Call WinBioIdentifyWithCallback. The method is asynchronous
// and returns immediately.
wprintf_s(L"\n Calling WinBioIdentifyWithCallback");
wprintf_s(L"\n Swipe the sensor ...\n");
hr = WinBioIdentifyWithCallback(
sessionHandle, // Open biometric session
IdentifyCallback, // Callback function
NULL // Optional context
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioIdentifyWithCallback failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Cancel user 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 WinBioIdentifyWithCallback.
// The function filters the response from the biometric subsystem and
// writes a result to the console window.
//
VOID CALLBACK IdentifyCallback(
__in_opt PVOID IdentifyCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_UNIT_ID UnitId,
__in WINBIO_IDENTITY *Identity,
__in WINBIO_BIOMETRIC_SUBTYPE SubFactor,
__in WINBIO_REJECT_DETAIL RejectDetail
)
{
UNREFERENCED_PARAMETER(IdentifyCallbackContext);
UNREFERENCED_PARAMETER(Identity);
wprintf_s(L"\n IdentifyCallback executing");
wprintf_s(L"\n Swipe processed for unit ID %d\n", UnitId);
// The attempt to process the fingerprint failed.
if (FAILED(OperationStatus))
{
if (OperationStatus == WINBIO_E_UNKNOWN_ID)
{
wprintf_s(L"\n Unknown identity.\n");
}
else if (OperationStatus == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Bad capture; reason: %d\n", RejectDetail);
}
else
{
wprintf_s(L"IdentifyCallback failed.");
wprintf_s(L"OperationStatus = 0x%x\n", OperationStatus);
}
}
// Processing succeeded and the finger swiped is written
// to the console window.
else
{
wprintf_s(L"\n The following finger was used:");
switch (SubFactor)
{
case WINBIO_SUBTYPE_NO_INFORMATION:
wprintf_s(L"\n No information\n");
break;
case WINBIO_ANSI_381_POS_RH_THUMB:
wprintf_s(L"\n RH thumb\n");
break;
case WINBIO_ANSI_381_POS_RH_INDEX_FINGER:
wprintf_s(L"\n RH index finger\n");
break;
case WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER:
wprintf_s(L"\n RH middle finger\n");
break;
case WINBIO_ANSI_381_POS_RH_RING_FINGER:
wprintf_s(L"\n RH ring finger\n");
break;
case WINBIO_ANSI_381_POS_RH_LITTLE_FINGER:
wprintf_s(L"\n RH little finger\n");
break;
case WINBIO_ANSI_381_POS_LH_THUMB:
wprintf_s(L"\n LH thumb\n");
break;
case WINBIO_ANSI_381_POS_LH_INDEX_FINGER:
wprintf_s(L"\n LH index finger\n");
break;
case WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER:
wprintf_s(L"\n LH middle finger\n");
break;
case WINBIO_ANSI_381_POS_LH_RING_FINGER:
wprintf_s(L"\n LH ring finger\n");
break;
case WINBIO_ANSI_381_POS_LH_LITTLE_FINGER:
wprintf_s(L"\n LH little finger\n");
break;
case WINBIO_SUBTYPE_ANY:
wprintf_s(L"\n Any finger\n");
break;
default:
break;
}
}
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows 7 [僅限傳統型應用程式] |
最低支援的伺服器 | Windows Server 2008 R2 [僅限傳統型應用程式] |
目標平台 | Windows |
標頭 | winbio.h |