共用方式為


WinBioCaptureSampleWithCallback 函式 (winbio.h)

以非同步方式擷取生物特徵辨識樣本,並在生物特徵辨識資訊記錄 (BIR) 中傳回原始或已處理的資料。 函式會立即傳回呼叫端、在個別執行緒上擷取範例,並呼叫應用程式定義的回呼函式來更新作業狀態。

  

建議您從 Windows 8 開始,不再使用此函式來啟動非同步作業。 請改為執行下列動作:

  • 實作 PWINBIO_ASYNC_COMPLETION_CALLBACK 函式,以便在作業完成時接收通知。
  • 呼叫 WinBioAsyncOpenSession 函式。 在 CallbackRoutine 參數中傳遞回呼的位址。 在 NotificationMethod 參數中傳遞WINBIO_ASYNC_NOTIFY_CALLBACK。 擷取非同步工作階段控制碼。
  • 使用非同步會話控制碼來呼叫 WinBioCaptureSample。 作業完成時,Windows 生物特徵辨識架構會使用結果配置和初始化 WINBIO_ASYNC_RESULT 結構,並使用結果結構的指標叫用回呼。
  • 從回呼實作呼叫 WinBioFree ,以在完成使用之後釋放 WINBIO_ASYNC_RESULT 結構。
 

語法

HRESULT WinBioCaptureSampleWithCallback(
  [in]           WINBIO_SESSION_HANDLE    SessionHandle,
  [in]           WINBIO_BIR_PURPOSE       Purpose,
  [in]           WINBIO_BIR_DATA_FLAGS    Flags,
  [in]           PWINBIO_CAPTURE_CALLBACK CaptureCallback,
  [in, optional] PVOID                    CaptureCallbackContext
);

參數

[in] SessionHandle

識別開啟生物特徵辨識工作階段的 WINBIO_SESSION_HANDLE 值。

[in] Purpose

指定範例預期用途的 WINBIO_BIR_PURPOSE 位遮罩。 這可以是下列值的位元 OR

  • WINBIO_PURPOSE_VERIFY
  • WINBIO_PURPOSE_IDENTIFY
  • WINBIO_PURPOSE_ENROLL
  • WINBIO_PURPOSE_ENROLL_FOR_VERIFICATION
  • WINBIO_PURPOSE_ENROLL_FOR_IDENTIFICATION

[in] Flags

指定要套用至擷取樣本的處理類型的值。 這可以是下列安全性和處理層級旗標的位元 OR

  • WINBIO_DATA_FLAG_PRIVACY

加密範例。

  • WINBIO_DATA_FLAG_INTEGRITY

簽署範例或使用訊息驗證碼 (MAC) 來保護它。

  • WINBIO_DATA_FLAG_SIGNED

如果已設定此旗標和WINBIO_DATA_FLAG_INTEGRITYflag,請簽署範例。 如果未設定此旗標,但已設定WINBIO_DATA_FLAG_INTEGRITY旗標,請計算 MAC。

  • WINBIO_DATA_FLAG_RAW

將樣品完全按照傳感器捕獲的方式返回。

  • WINBIO_DATA_FLAG_INTERMEDIATE

清潔和過濾後返回樣品。

  • WINBIO_DATA_FLAG_PROCESSED

在樣品準備好用於標記<用途>/標記<參數指定的>目的後,將其傳回。

[in] CaptureCallback

當擷取作業成功或失敗時, WinBioCaptureSampleWithCallback 函式將呼叫回呼函式的位址。 您必須建立回呼。

[in, optional] CaptureCallbackContext

應用程式定義資料結構的位址,傳遞至其 CaptureCallbackContext 參數中的回呼函式。 此結構可以包含自訂回呼函式設計要處理的任何資料。

傳回值

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

傳回碼 Description
E_ACCESSDENIED
呼叫端沒有擷取原始範例的許可權,或未使用 WINBIO_FLAG_RAW 旗標開啟會話。
E_HANDLE
工作階段控制碼無效。
E_NOTIMPL
生物特徵辨識單位不支援要求的作業。
E_POINTER
UnitIdSampleSampleSizeRejectDetail 指標不能是 NULL。
WINBIO_E_ENROLLMENT_IN_PROGRESS
無法完成作業,因為生物特徵辨識單位目前正用於註冊交易 (僅限系統集區) 。

備註

WinBioCaptureSampleWithCallback 函式會以非同步方式擷取範例。 若要成功呼叫此函式,必須指定 WINBIO_FLAG_RAW 來開啟會話句柄。 只有管理員和本機系統帳戶具有必要的權限。

「用途」「旗標」參數的有效組合取決於所使用的生物特徵辨識單位的功能。 請參閱廠商感應器文件,以判斷支援哪些組合,以及它們如何影響擷取的資料。

呼叫端負責釋放 Sample 參數所傳回的WINBIO_BIR結構。

回呼常式必須具有下列簽章:

VOID CALLBACK CaptureCallback(
__in_opt PVOID CaptureCallbackContext,
__in HRESULT OperationStatus,
__in WINBIO_UNIT_ID UnitId,
__in_bcount(SampleSize) PWINBIO_BIR Sample,
__in SIZE_T SampleSize,
__in WINBIO_REJECT_DETAIL RejectDetail
);

範例

下列程式碼範例會呼叫 WinBioCaptureSampleWithCallback ,並將指標傳遞至自訂回呼函式,以非同步方式擷取範例。 也會顯示回呼函式 CaptureSampleCallback。 連結至 Winbio.lib 靜態程式庫,並包含下列標頭檔:

  • Windows.h
  • 標準.h
  • Conio.h
  • Winbio.h
HRESULT CaptureSampleWithCallback(BOOL bCancel)
{
    HRESULT hr = S_OK;
    WINBIO_SESSION_HANDLE sessionHandle = NULL;

    // Connect to the system pool. 
    hr = WinBioOpenSession( 
            WINBIO_TYPE_FINGERPRINT,    // Service provider
            WINBIO_POOL_SYSTEM,         // Pool type
            WINBIO_FLAG_RAW,            // Raw access
            NULL,                       // Array of biometric unit IDs
            0,                          // Count of biometric unit IDs
            WINBIO_DB_DEFAULT,          // Default database
            &sessionHandle              // [out] Session handle
            );
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioOpenSession failed. hr = 0x%x\n", hr);
        goto e_Exit;
    }

    // Capture a biometric sample asynchronously.
    wprintf_s(L"\n Calling WinBioCaptureSampleWithCallback ");
    hr = WinBioCaptureSampleWithCallback(
            sessionHandle,                  // Open session handle
            WINBIO_NO_PURPOSE_AVAILABLE,    // Intended use of the sample
            WINBIO_DATA_FLAG_RAW,           // Sample format
            CaptureSampleCallback,          // Callback function
            NULL                            // Optional context
            );
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
        wprintf_s(L"hr = 0x%x\n", hr);
        goto e_Exit;
    }
    wprintf_s(L"\n Swipe the sensor ...\n");

    // Cancel the capture process if the bCancel flag is set.
    if (bCancel)
    {
        wprintf_s(L"\n Starting CANCEL timer...");
        Sleep( 7000 );

        wprintf_s(L"\n Calling WinBioCancel\n");
        hr = WinBioCancel( sessionHandle );
        if (FAILED(hr))
        {
            wprintf_s(L"\n WinBioCancel failed. hr = 0x%x\n", hr);
            goto e_Exit;
        }
    }

    // Wait for the asynchronous capture process to complete 
    // or be canceled.
    hr = WinBioWait( sessionHandle );
    if (FAILED(hr))
    {
        wprintf_s(L"\n WinBioWait failed. hr = 0x%x\n", hr);
    }

e_Exit:

    if (sessionHandle != NULL)
    {
        WinBioCloseSession(sessionHandle);
        sessionHandle = NULL;
    }

    wprintf_s(L"\n Press any key to exit...");
    _getch();

    return hr;
}

//------------------------------------------------------------------------
// The following function is the callback for WinBioCaptureSampleWithCallback.
// The function filters the response from the biometric subsystem and 
// writes a result to the console window.
//
VOID CALLBACK CaptureSampleCallback(
    __in_opt PVOID CaptureCallbackContext,
    __in HRESULT OperationStatus,
    __in WINBIO_UNIT_ID UnitId,
    __in_bcount(SampleSize) PWINBIO_BIR Sample,
    __in SIZE_T SampleSize,
    __in WINBIO_REJECT_DETAIL RejectDetail
    )
{
    UNREFERENCED_PARAMETER(CaptureCallbackContext);

    wprintf_s(L"\n CaptureSampleCallback executing");
    wprintf_s(L"\n Swipe processed - Unit ID: %d", UnitId);

    if (FAILED(OperationStatus))
    {
        if (OperationStatus == WINBIO_E_BAD_CAPTURE)
        {
            wprintf_s(L"\n Bad capture; reason: %d\n", RejectDetail);
         }
        else
        {
            wprintf_s(L"\n WinBioCaptureSampleWithCallback failed. ");
            wprintf_s(L" OperationStatus = 0x%x\n", OperationStatus);
        }
        goto e_Exit;
    }

    wprintf_s(L"\n Captured %d bytes.\n", SampleSize);

e_Exit:

    if (Sample != NULL)
    {
        WinBioFree(Sample);
        Sample = NULL;
    }
}


需求

Requirement 價值觀
最低支援的用戶端 Windows 7 [僅限傳統型應用程式]
支援的最低伺服器 Windows Server 2008 R2 [僅限傳統型應用程式]
目標平臺 窗戶
Header winbio.h(包括Winbio.h)
Library Winbio.lib 網站
DLL檔案 Winbio.dll

另請參閱

WinBioCapture範例