Share via


WinBioEnumEnrollments 函式 (winbio.h)

擷取針對指定身分識別和生物特徵辨識單位註冊的生物特徵辨識子因素。 從 Windows 10 組建 1607 開始,此函式可用來搭配行動映射使用。

語法

HRESULT WinBioEnumEnrollments(
  [in]            WINBIO_SESSION_HANDLE    SessionHandle,
  [in]            WINBIO_UNIT_ID           UnitId,
  [in]            WINBIO_IDENTITY          *Identity,
                  WINBIO_BIOMETRIC_SUBTYPE **SubFactorArray,
  [out, optional] SIZE_T                   *SubFactorCount
);

參數

[in] SessionHandle

識別開放式生物特徵辨識會話 的WINBIO_SESSION_HANDLE 值。 呼叫 WinBioOpenSession 來開啟同步會話句柄。 呼叫 WinBioAsyncOpenSession 來開啟異步會話句柄。

[in] UnitId

指定生物特徵辨識單位 的WINBIO_UNIT_ID 值。

[in] Identity

包含要從中擷取子因素之範本 GUID 或 SID 之 WINBIO_IDENTITY 結構的指標。

SubFactorArray

接收子因素陣列指標的變數位址。 如果函式不成功,指標會設定為 NULL。 如果函式成功,您必須將指標傳遞至 WinBioFree ,以釋放內部配置給數位的記憶體。

[out, optional] SubFactorCount

值的指標,指定 SubFactorArray 參數所指向之陣列中的項目數目。 如果函式不成功,此值會設定為零。

傳回值

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

傳回碼 Description
E_HANDLE
會話句柄無效。
E_INVALIDARG
UnitId 參數不可為零。
E_POINTER
IdentitySubFactorArraySubFactorCount 參數不能是 NULL
WINBIO_E_ENROLLMENT_IN_PROGRESS
作業無法完成,因為 UnitId 參數指定的生物特徵辨識單位目前正在用於註冊交易。
WINBIO_E_UNKNOWN_ID
找不到 Identity 參數指定的 GUID 或 SID。

備註

WinBioEnumEnrollments 函式主要是提供,讓應用程式可以提供使用者意見反應。 例如,您的應用程式可以呼叫此函式,告知使用者哪些指紋已在特定指紋讀取器上註冊。

使用傳回 至 SubFactorArray 參數的結構之後,您必須呼叫 WinBioFree ,以釋放內部配置給數位的記憶體。

若要以同步方式使用 WinBioEnumEnrollments ,請使用呼叫 WinBioOpenSession 所建立的會話句柄呼叫函式。 函式會封鎖直到作業完成或發生錯誤為止。

若要以異步方式使用 WinBioEnumEnrollments ,請使用呼叫 WinBioAsyncOpenSession 所建立的會話句柄呼叫函式。 架構會配置 WINBIO_ASYNC_RESULT 結構,並用它來傳回作業成功或失敗的相關信息。 如果作業成功,架構會傳回EnumEnrollments 結構中的WINBIO_IDENTITY和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指標。
若要防止記憶體流失,您必須呼叫 WinBioFree ,以在您使用完 之後釋放WINBIO_ASYNC_RESULT 結構。

範例

下列函式會呼叫 WinBioEnumEnrollments 來列舉為範本註冊的生物特徵辨識子因素。 連結到Winbio.lib 靜態庫,並包含下列頭檔:

  • Windows.h
  • Stdio.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;
}


規格需求

需求
最低支援的用戶端 Windows 7 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 R2 [僅限傳統型應用程式]
目標平台 Windows
標頭 winbio.h (包含Winbio.h)
程式庫 Winbio.lib
Dll Winbio.dll

另請參閱

WinBioEnumBiometricUnits

WinBioEnumDatabases

WinBioEnumServiceProviders