完成待審核的生物辨識範本,並將其儲存到與用於註冊的生物辨識單位相關的資料庫。 從 Windows 10 版本 1607 開始,此功能可用於行動映像檔。
語法
HRESULT WinBioEnrollCommit(
[in] WINBIO_SESSION_HANDLE SessionHandle,
[out, optional] WINBIO_IDENTITY *Identity,
[out, optional] BOOLEAN *IsNewTemplate
);
參數
[in] SessionHandle
識別開啟生物特徵辨識工作階段的 WINBIO_SESSION_HANDLE 值。 呼叫 WinBioOpenSession 開啟同步會話的 handle 。 透過呼叫 WinBioAsyncOpenSession 開啟非同步會話句柄。
[out, optional] Identity
指標指向一個接收範本識別碼(GUID 或 SID)的 WINBIO_IDENTITY 結構。
[out, optional] IsNewTemplate
指標指向一個布林值,指定新增到資料庫的範本是否全新。
返回值
如果函式成功,則會傳回S_OK。 如果函式失敗,它會傳回指出錯誤的 HRESULT 值。 可能的值包括但不限於下表中的值。 如需常見錯誤碼的清單,請參閱 常見的 HRESULT 值。
| 回傳碼 | Description |
|---|---|
|
工作階段控制碼無效。 |
|
由 Identity 與 IsNewTemplate 參數指定的指標不能是 NULL。 |
|
資料庫中沒有空間放置該範本。 |
|
該範本與資料庫中已存的範本相符,但其身份或子因素不同(僅限系統池)。 |
|
生物辨識裝置正在使用且已鎖定。 |
備註
若待處理範本與資料庫中已有範本重複,Identity 參數將指向現有範本,而 IsNewTemplate 參數指向的值為 FALSE。
若 WinBioEnrollCommit 函式成功,以下登錄檔值將設為 0x01。
HKEY_LOCAL_MACHINE System CurrentControlSet Services WbioSrvc Parameters EnrollmentCommitted
若要非同步使用 WinBioEnrollCommit ,請呼叫該函式,並呼叫由 WinBioAsyncOpenSession 建立的會話句柄。 該框架分配一個 WINBIO_ASYNC_RESULT 結構,並用它來回傳有關操作成功或失敗的資訊。 若操作成功,框架會回傳 WINBIO_IDENTITY 資訊及一個旗標,指示該範本是否為巢狀 EnrollCommit 結構中的新版本。 若操作失敗,框架會回傳錯誤資訊。 WINBIO_ASYNC_RESULT結構會根據您在 WinBioAsyncOpenSession 函式的 NotificationMethod 參數中設定的值,回傳到應用程式回撥或應用程式訊息佇列:
- 如果你選擇透過回撥接收完成通知,必須實作 一個PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,並將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_CALLBACK。
- 如果你選擇透過應用程式訊息隊列接收完成通知,必須將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_MESSAGE。 框架回傳一個指向視窗訊息 LPARAM 欄位的 WINBIO_ASYNC_RESULT指標。
範例
以下函式呼叫 WinBioEnrollCommit 來向系統池提交生物特徵登錄。 連結至 Winbio.lib 靜態程式庫,並包含下列標頭檔:
- Windows.h
- 標準.h
- Conio.h
- Winbio.h
HRESULT EnrollSysPool(
BOOL discardEnrollment,
WINBIO_BIOMETRIC_SUBTYPE subFactor)
{
HRESULT hr = S_OK;
WINBIO_IDENTITY identity = {0};
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
WINBIO_REJECT_DETAIL rejectDetail = 0;
BOOLEAN isNewTemplate = TRUE;
// 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. ");
wprintf_s(L"hr = 0x%x\n", hr);
goto e_Exit;
}
// Locate a sensor.
wprintf_s(L"\n Swipe your finger on the sensor...\n");
hr = WinBioLocateSensor( sessionHandle, &unitId);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Begin the enrollment sequence.
wprintf_s(L"\n Starting enrollment sequence...\n");
hr = WinBioEnrollBegin(
sessionHandle, // Handle to open biometric session
subFactor, // Finger to create template for
unitId // Biometric unit ID
);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollBegin failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Capture enrollment information by swiping the sensor with
// the finger identified by the subFactor argument in the
// WinBioEnrollBegin function.
for (int swipeCount = 1;; ++swipeCount)
{
wprintf_s(L"\n Swipe the sensor to capture %s sample.",
(swipeCount == 1)?L"the first":L"another");
hr = WinBioEnrollCapture(
sessionHandle, // Handle to open biometric session
&rejectDetail // [out] Failure information
);
wprintf_s(L"\n Sample %d captured from unit number %d.",
swipeCount,
unitId);
if (hr == WINBIO_I_MORE_DATA)
{
wprintf_s(L"\n More data required.\n");
continue;
}
if (FAILED(hr))
{
if (hr == WINBIO_E_BAD_CAPTURE)
{
wprintf_s(L"\n Error: Bad capture; reason: %d",
rejectDetail);
continue;
}
else
{
wprintf_s(L"\n WinBioEnrollCapture failed. hr = 0x%x", hr);
goto e_Exit;
}
}
else
{
wprintf_s(L"\n Template completed.\n");
break;
}
}
// Discard the enrollment if the appropriate flag is set.
// Commit the enrollment if it is not discarded.
if (discardEnrollment == TRUE)
{
wprintf_s(L"\n Discarding enrollment...\n\n");
hr = WinBioEnrollDiscard( sessionHandle );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLocateSensor failed. hr = 0x%x\n", hr);
}
goto e_Exit;
}
else
{
wprintf_s(L"\n Committing enrollment...\n");
hr = WinBioEnrollCommit(
sessionHandle, // Handle to open biometric session
&identity, // WINBIO_IDENTITY object for the user
&isNewTemplate); // Is this a new template
if (FAILED(hr))
{
wprintf_s(L"\n WinBioEnrollCommit failed. hr = 0x%x\n", hr);
goto e_Exit;
}
}
e_Exit:
if (sessionHandle != NULL)
{
WinBioCloseSession(sessionHandle);
sessionHandle = NULL;
}
wprintf_s(L" Press any key to continue...");
_getch();
return hr;
}
需求
| Requirement | 價值觀 |
|---|---|
| 最低支援的用戶端 | Windows 7 [僅限桌面應用程式] |
| 支援的最低伺服器 | Windows Server 2008 R2 [僅限傳統型應用程式] |
| 目標平臺 | 窗戶 |
| Header | winbio.h(包括Winbio.h) |
| Library | Winbio.lib 網站 |
| DLL | Winbio.dll |