PWINBIO_IDENTIFY_CALLBACK回调函数 (winbio.h)
PWINBIO_IDENTIFY_CALLBACK 函数由 Windows 生物识别框架调用,以从异步 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
生物识别单元 ID 号。
[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 |