解除指定生物辨識單元的會話鎖定。
語法
HRESULT WinBioUnlockUnit(
[in] WINBIO_SESSION_HANDLE SessionHandle,
[in] WINBIO_UNIT_ID UnitId
);
參數
[in] SessionHandle
識別開啟生物特徵辨識工作階段的 WINBIO_SESSION_HANDLE 值。 呼叫 WinBioOpenSession 開啟同步會話的 handle 。 透過呼叫 WinBioAsyncOpenSession 開啟非同步會話句柄。
[in] UnitId
一個 WINBIO_UNIT_ID 值,指定要解鎖的生物識別單位。
返回值
如果函式成功,則會傳回S_OK。 如果函式失敗,它會傳回指出錯誤的 HRESULT 值。 可能的值包括但不限於下表中的值。 如需常見錯誤碼的清單,請參閱 常見的 HRESULT 值。
| 回傳碼 | Description |
|---|---|
|
工作階段控制碼無效。 |
|
UnitId 參數不可能包含零。 |
|
UnitId 參數指定的生物特徵單元目前尚未被會話鎖定。 |
備註
呼叫 WinBioUnlockUnit 會自動解除該工作階段所持有的任何鎖。 若 UnitId 指定的生物特徵單元尚未透過呼叫 WinBioLockUnit 函式被鎖定,該函式將失敗。
要同步使用 WinBioUnlockUnit ,請呼叫該函式,並透過呼叫 WinBioOpenSession 建立會話代碼。 該函式會阻塞,直到操作完成或遇到錯誤。
若要非同步使用 WinBioUnlockUnit ,請呼叫該函式,並透過呼叫 WinBioAsyncOpenSession 建立的會話句柄。 該框架分配一個 WINBIO_ASYNC_RESULT 結構,並用它來回傳有關操作成功或失敗的資訊。 WINBIO_ASYNC_RESULT結構會根據您在 WinBioAsyncOpenSession 函式的 NotificationMethod 參數中設定的值,回傳到應用程式回撥或應用程式訊息佇列:
- 如果你選擇透過回撥接收完成通知,必須實作 一個PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,並將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_CALLBACK。
- 如果你選擇透過應用程式訊息隊列接收完成通知,必須將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_MESSAGE。 框架回傳一個指向視窗訊息 LPARAM 欄位的 WINBIO_ASYNC_RESULT指標。
範例
以下函式呼叫 WinBioLockUnit 鎖定生物辨識單元,再呼叫 WinBioIdentify 以識別使用者。 它會呼叫 WinBioUnlockUnit 來解鎖生物特徵 union,然後再關閉開啟的會話。 連結至 Winbio.lib 靜態程式庫,並包含下列標頭檔:
- Windows.h
- 標準.h
- Conio.h
- Winbio.h
HRESULT LockUnlock( )
{
// Declare variables.
HRESULT hr = S_OK;
WINBIO_IDENTITY identity = {0};
WINBIO_SESSION_HANDLE sessionHandle = NULL;
WINBIO_UNIT_ID unitId = 0;
WINBIO_REJECT_DETAIL rejectDetail = 0;
WINBIO_BIOMETRIC_SUBTYPE subFactor = WINBIO_SUBTYPE_NO_INFORMATION;
BOOL lockAcquired = FALSE;
// 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 WinBioEnumBiometricUnits failed. hr = 0x%x\n", hr);
goto e_Exit;
}
// Lock the session. The Biometric unit ID (1) is hard coded in
// this example.
hr = WinBioLockUnit( sessionHandle, 1 );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioLockUnit failed. hr = 0x%x\n", hr);
goto e_Exit;
}
wprintf_s(L"\n Biometric unit #1 is locked.\n");
lockAcquired = TRUE;
// Locate the biometric sensor and retrieve a WINBIO_IDENTITY object.
// You must swipe your finger on the sensor.
wprintf_s(L"\n Calling WinBioIdentify - Swipe finger on sensor...\n");
hr = WinBioIdentify(
sessionHandle,
&unitId,
&identity,
&subFactor,
&rejectDetail
);
wprintf_s(L"\n Swipe processed - Unit ID: %d\n", unitId);
if (FAILED(hr))
{
wprintf_s(L"\n WinBioIdentify failed. hr = 0x%x\n", hr);
goto e_Exit;
}
e_Exit:
// Unlock the biometric unit if it is locked.
if (lockAcquired == TRUE)
{
hr = WinBioUnlockUnit( sessionHandle, 1 );
if (FAILED(hr))
{
wprintf_s(L"\n WinBioUnlockUnit failed. hr = 0x%x\n", hr);
}
wprintf_s(L"\n Biometric unit #1 is unlocked.\n");
lockAcquired = FALSE;
}
if (sessionHandle != NULL)
{
WinBioCloseSession(sessionHandle);
sessionHandle = NULL;
}
wprintf_s(L"\n Press any key to exit...");
_getch();
return hr;
}
需求
| Requirement | 價值觀 |
|---|---|
| 最低支援的用戶端 | Windows 7 [僅限桌面應用程式] |
| 支援的最低伺服器 | Windows Server 2008 R2 [僅限傳統型應用程式] |
| 目標平臺 | 窗戶 |
| Header | winbio.h(包括Winbio.h) |
| Library | Winbio.lib 網站 |
| DLL | Winbio.dll |