共用方式為


WinBioIdentify 函式(winbio.h)

擷取生物特徵樣本,判斷是否符合現有的生物特徵範本。 從 Windows 10 版本 1607 開始,此功能可用於行動映像檔。

語法

HRESULT WinBioIdentify(
  [in]            WINBIO_SESSION_HANDLE    SessionHandle,
  [out, optional] WINBIO_UNIT_ID           *UnitId,
  [out, optional] WINBIO_IDENTITY          *Identity,
  [out, optional] WINBIO_BIOMETRIC_SUBTYPE *SubFactor,
  [out, optional] WINBIO_REJECT_DETAIL     *RejectDetail
);

參數

[in] SessionHandle

識別開啟生物特徵辨識工作階段的 WINBIO_SESSION_HANDLE 值。 呼叫 WinBioOpenSession 開啟同步會話的 handle 。 透過呼叫 WinBioAsyncOpenSession 開啟非同步會話句柄。

[out, optional] UnitId

指向一個 ULONG 值的指標,該值指定用於進行識別的生物特徵單位。

[out, optional] Identity

指標指向一個 WINBIO_IDENTITY 結構,該結構接收提供生物特徵樣本使用者的 GUID 或 SID。

[out, optional] SubFactor

指標指向接收與生物特徵樣本相關子因子的 WINBIO_BIOMETRIC_SUBTYPE 值。 詳情請參閱備註區。

[out, optional] RejectDetail

指向 一個 ULONG 值的指標,該值包含關於生物特徵樣本捕捉失敗(若有的話)的額外資訊。 若捕獲成功,該參數為零。 下列值會針對指紋擷取定義:

  • 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

返回值

如果函式成功,則會傳回S_OK。 如果函式失敗,它會傳回指出錯誤的 HRESULT 值。 可能的值包括但不限於下表中的值。 如需常見錯誤碼的清單,請參閱 常見的 HRESULT 值

回傳碼 Description
E_HANDLE
工作階段控制碼無效。
E_POINTER
UnitIdIdentitySubFactorRejectDetail 參數指定的指標不能是 NULL。
WINBIO_E_BAD_CAPTURE
該樣本無法被捕捉。 請使用 RejectDetail 值以獲得更多資訊。
WINBIO_E_ENROLLMENT_IN_PROGRESS
無法完成作業,因為生物特徵辨識單位目前正用於註冊交易 (僅限系統集區) 。
WINBIO_E_UNKNOWN_ID
生物辨識樣本與資料庫中任何儲存的樣本不符。

備註

子因子參數中回傳的值指定與生物特徵樣本相關的子因子。 Windows 生物特徵框架(WBF)目前僅支援指紋擷取,並使用以下常數來表示子類型資訊。

  • 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
若要同步使用 WinBioIdentity ,請呼叫該函式,並以呼叫 WinBioOpenSession 所建立的 session 句柄。 該函式會阻塞,直到操作完成或遇到錯誤。

若要非同步使用 WinBioIdentity ,請呼叫該函式,並呼叫由 WinBioAsyncOpenSession 建立的會話句柄。 該框架分配一個 WINBIO_ASYNC_RESULT 結構,並用它來回傳有關操作成功或失敗的資訊。 若操作成功,框架會以巢狀的 Identify 結構回傳WINBIO_IDENTITYWINBIO_BIOMETRIC_SUBTYPE 資訊。 若操作失敗,框架會在 Identify 結構中回傳WINBIO_REJECT_DETAIL資訊。 WINBIO_ASYNC_RESULT結構會根據您在 WinBioAsyncOpenSession 函式的 NotificationMethod 參數中設定的值,回傳到應用程式回撥或應用程式訊息佇列:

  • 如果你選擇透過回撥接收完成通知,必須實作 一個PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,並將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_CALLBACK
  • 如果你選擇透過應用程式訊息隊列接收完成通知,必須將 NotificationMethod 參數設為 WINBIO_ASYNC_NOTIFY_MESSAGE。 框架回傳一個指向視窗訊息 LPARAM 欄位的 WINBIO_ASYNC_RESULT指標。
為防止記憶體洩漏,使用完成後必須呼叫 WinBioFree 釋放 WINBIO_ASYNC_RESULT 結構。

Windows 7: 你可以透過 WinBioIdentifyWithCallback 函式非同步執行此操作。 函式會驗證輸入參數並立即回傳。 若輸入參數無效,函式會回傳錯誤碼。 否則,框架會在另一個執行緒開始操作。 當非同步操作完成或遇到錯誤時,框架會將結果傳送給你應用程式實作的 PWINBIO_IDENTIFY_CALLBACK 函式。

範例

以下函式呼叫 WinBioEnumEnrollments 以列舉模板所登記的生物特徵子因子,並呼叫 WinBioIdentify 以取得識別使用者的 WINBIO_IDENTITY 物件。 連結至 Winbio.lib 靜態程式庫,並包含下列標頭檔:

  • Windows.h
  • 標準.h
  • Conio.h
  • Winbio.h
HRESULT EnumEnrollments( )
{
    // Declare variables.
    HRESULT hr = S_OK;
    WINBIO_IDENTITY identity = {0};
    WINBIO_SESSION_HANDLE sessionHandle = NULL;
    WINBIO_UNIT_ID unitId = 0;
    PWINBIO_BIOMETRIC_SUBTYPE subFactorArray = NULL;
    WINBIO_BIOMETRIC_SUBTYPE SubFactor = 0;
    SIZE_T subFactorCount = 0;
    WINBIO_REJECT_DETAIL rejectDetail = 0;
    WINBIO_BIOMETRIC_SUBTYPE subFactor = WINBIO_SUBTYPE_NO_INFORMATION;

    // 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. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    // Locate the biometric sensor and retrieve a WINBIO_IDENTITY object.
    wprintf_s(L"\n Calling WinBioIdentify - Swipe finger on sensor...\n");
    hr = WinBioIdentify( 
            sessionHandle,              // Session handle
            &unitId,                    // Biometric unit ID
            &identity,                  // User SID
            &subFactor,                 // Finger sub factor
            &rejectDetail               // Rejection information
            );
    wprintf_s(L"\n Swipe processed - Unit ID: %d\n", unitId);
    if (FAILED(hr))
    {
        if (hr == WINBIO_E_UNKNOWN_ID)
        {
            wprintf_s(L"\n Unknown identity.\n");
        }
        else if (hr == WINBIO_E_BAD_CAPTURE)
        {
            wprintf_s(L"\n Bad capture; reason: %d\n", rejectDetail);
        }
        else
        {
            wprintf_s(L"\n WinBioEnumBiometricUnits failed. hr = 0x%x\n", hr);
        }
        goto e_Exit;
    }

    // Retrieve the biometric sub-factors for the template.
    hr = WinBioEnumEnrollments( 
            sessionHandle,              // Session handle
            unitId,                     // Biometric unit ID
            &identity,                  // Template ID
            &subFactorArray,            // Subfactors
            &subFactorCount             // Count of subfactors
            );
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioEnumEnrollments failed. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    // Print the sub-factor(s) to the console.
    wprintf_s(L"\n Enrollments for this user on Unit ID %d:", unitId);
    for (SIZE_T index = 0; index < subFactorCount; ++index)
    {
        SubFactor = subFactorArray[index];
        switch (SubFactor)
        {
            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;
            default:
                wprintf_s(L"\n   The sub-factor is not correct\n");
                break;
        }
 
    }

e_Exit:
    if (subFactorArray!= NULL)
    {
        WinBioFree(subFactorArray);
        subFactorArray = NULL;
    }

    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

另請參閱

WinBioIdentifyWithCallback