啟動生物辨識註冊序列並建立一個空的生物辨識範本。 從 Windows 10 版本 1607 開始,此功能可用於行動映像檔。
語法
HRESULT WinBioEnrollBegin(
[in] WINBIO_SESSION_HANDLE SessionHandle,
[in] WINBIO_BIOMETRIC_SUBTYPE SubFactor,
[in] WINBIO_UNIT_ID UnitId
);
參數
[in] SessionHandle
識別開啟生物特徵辨識工作階段的 WINBIO_SESSION_HANDLE 值。 呼叫 WinBioOpenSession 開啟同步會話的 handle 。 透過呼叫 WinBioAsyncOpenSession 開啟非同步會話句柄。
[in] SubFactor
一個 WINBIO_BIOMETRIC_SUBTYPE 值,提供關於登記的額外資訊。 此值必須是以下之一:
- WINBIO_ANSI_381_POS_RH_THUMB
- WINBIO_ANSI_381_POS_RH_INDEX_FINGER
- WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER
- WINBIO_ANSI_381_POS_RH_RING_FINGER
- WINBIO_ANSI_381_POS_RH_LITTLE_FINGER
- WINBIO_ANSI_381_POS_LH_THUMB
- WINBIO_ANSI_381_POS_LH_INDEX_FINGER
- WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER
- WINBIO_ANSI_381_POS_LH_RING_FINGER
- WINBIO_ANSI_381_POS_LH_LITTLE_FINGER
- WINBIO_ANSI_381_POS_RH_FOUR_FINGERS
- WINBIO_ANSI_381_POS_LH_FOUR_FINGERS
[in] UnitId
一個 WINBIO_UNIT_ID 值,用來識別生物特徵單位。 這個值不可能是零。 您可以透過呼叫 WinBioEnumBiometricUnits 或 WinBioLocateSensor 函式來找到單位 ID。
返回值
如果函式成功,則會傳回S_OK。 如果函式失敗,它會傳回指出錯誤的 HRESULT 值。 可能的值包括但不限於下表中的值。 如需常見錯誤碼的清單,請參閱 常見的 HRESULT 值。
| 回傳碼 | Description |
|---|---|
|
來電者沒有註冊權限。 |
|
工作階段控制碼無效。 |
|
SubFactor 參數不能等於 WINBIO_SUBTYPE_NO_INFORMATION 或 WINBIO_SUBTYPE_ANY,UnitId 參數也不能等於零。 |
|
登記作業已經進行中,且同一時間只能進行一次登記。 |
|
生物辨識裝置正在使用且已鎖定。 |
備註
單一生物特徵登記需要從使用者那裡收集多個樣本。 任何時候只能進行一次登記操作,且所有適用於單一登記的生物特徵樣本都必須由同一感測器產生。 此感測器由 UnitId 參數指定。
任何透過系統池中生物辨識單元註冊的應用程式,在呼叫 WinBioEnrollBegin 時必須設定視窗焦點。 若未達成,呼叫會阻塞,直到應用程式取得視窗焦點且使用者提供生物特徵樣本。 因此,我們建議您的應用程式在獲得焦點之前,不要呼叫 WinBioEnrollBegin 。 你如何獲得專注,取決於你所撰寫的申請類型。 舉例來說,如果你正在建立一個圖形使用者體驗應用程式,你可以實作一個訊息處理器來捕捉WM_ACTIVATE、WM_SETFOCUS或其他適當的訊息。 如果你正在撰寫 CUI 應用程式,呼叫 GetConsoleWindow 取得主控台視窗的 handle,並將該 handle 傳給 SetForegroundWindow 函式,強制將主控台視窗移到前景並指派焦點。 如果你的應用程式是在分離程序中執行且沒有視窗,或是 Windows 服務,請使用 WinBioAcquireFocus 和 WinBioReleaseFocus 手動控制焦點。
要同步使用 WinBioEnrollBegin ,請呼叫該函式,並呼叫由 WinBioOpenSession 建立的會話句柄。 該函式會阻塞,直到操作完成或遇到錯誤。
若要非同步使用 WinBioEnrollBegin ,請呼叫該函式,並透過呼叫 WinBioAsyncOpenSession 建立的會話句柄。 該框架分配一個 WINBIO_ASYNC_RESULT 結構,並用它來回傳有關操作成功或失敗的資訊。 若操作成功,框架會以巢狀 EnrollBegin 結構回傳WINBIO_BIOMETRIC_SUBTYPE資訊。 若操作失敗,框架會回傳錯誤資訊。 WINBIO_ASYNC_RESULT結構會根據您在 WinBioAsyncOpenSession 函式的 NotificationMethod 參數中設定的值,回傳到應用程式回撥或應用程式訊息佇列:
- 如果你選擇透過回撥接收完成通知,必須實作 一個PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,並將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_CALLBACK。
- 如果你選擇透過應用程式訊息隊列接收完成通知,必須將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_MESSAGE。 框架回傳一個指向視窗訊息 LPARAM 欄位的 WINBIO_ASYNC_RESULT指標。
範例
以下函式會在系統池中註冊一個生物特徵範本。 它呼叫 WinBioEnrollBegin 來啟動註冊序列。 連結至 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 |
另請參閱
WinBioAcquireFocus(WinBioAcquireFocus)
WinBio註冊CaptureWithCallback(回撥)