取消指定会话的所有挂起生物识别作。 从 Windows 10 版本 1607 开始,此函数可用于移动映像。
Syntax
HRESULT WinBioCancel(
[in] WINBIO_SESSION_HANDLE SessionHandle
);
参数
[in] SessionHandle
标识开放生物识别会话 的WINBIO_SESSION_HANDLE 值。 通过调用 WinBioOpenSession 打开同步会话句柄。 通过调用 WinBioAsyncOpenSession 打开异步会话句柄。
返回值
如果函数成功,它将返回S_OK。 如果函数失败,它将返回指示错误的 HRESULT 值。 可能的值包括但不限于下表中的值。 有关常见错误代码的列表,请参阅 通用 HRESULT 值。
| 返回代码 | Description |
|---|---|
|
会话句柄无效。 |
注解
若要同步使用 WinBioCancel ,请使用通过调用 WinBioOpenSession 创建的会话句柄调用函数。 使用同步会话句柄调用函数时:
- 如果没有挂起的作,该函数将返回S_OK,并且不会执行其他任何作。
- 挂起的异步作会收到一个回调通知, OperationStatus 参数设置为 WINBIO_E_CANCELED。
- 进程中的其他线程启动的阻塞异步作返回 WINBIO_E_CANCELED。
- 该函数验证输入参数,并使用S_OK或错误代码立即返回。
- 挂起的异步作会收到一条完成通知,该通知将各自WINBIO_ASYNC_RESULT结构的 ApiStatus 成员设置为WINBIO_E_CANCELED。
- 如果选择使用回调接收完成通知,则必须实现 PWINBIO_ASYNC_COMPLETION_CALLBACK 函数并将 NotificationMethod 参数设置为 WINBIO_ASYNC_NOTIFY_CALLBACK。
- 如果选择使用应用程序消息队列接收完成通知,则必须将 NotificationMethod 参数设置为 WINBIO_ASYNC_NOTIFY_MESSAGE。 框架返回指向窗口消息的 LPARAM 字段的WINBIO_ASYNC_RESULT指针。
例子
下面的代码示例通过调用 WinBioCaptureSampleWithCallback 异步捕获示例。 可以将布尔值传递给函数,如果设置为 TRUE,则可以取消捕获作。 链接到 Winbio.lib 静态库,并包含以下头文件:
- Windows.h
- Stdio.h
- Conio.h
- 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 operation 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;
}
}
要求
| Requirement | 价值 |
|---|---|
| 最低支持的客户端 | Windows 7 [仅限桌面应用] |
| 支持的最低服务器 | Windows Server 2008 R2 [仅限桌面应用] |
| 目标平台 | Windows操作系统 |
| Header | winbio.h (包括 Winbio.h) |
| Library | Winbio.lib |
| DLL | Winbio.dll |