PIBIO_STORAGE_ATTACH_FNコールバック関数 (winbio_adapter.h)

ストレージ アダプターが生体認証ユニットの処理パイプラインに追加されるときに、Windows 生体認証フレームワークによって呼び出されます。 この関数の目的は、後の生体認証操作に必要な初期化を実行することです。

構文

PIBIO_STORAGE_ATTACH_FN PibioStorageAttachFn;

HRESULT PibioStorageAttachFn(
  [in, out] PWINBIO_PIPELINE Pipeline
)
{...}

パラメーター

[in, out] Pipeline

操作を実行する生体認証ユニットに関連付けられている WINBIO_PIPELINE 構造体へのポインター。

戻り値

関数が成功した場合は、S_OK を返します。 関数が失敗した場合は、次のいずれかの HRESULT 値を返してエラーを示す必要があります。

リターン コード 説明
E_POINTER
Pipeline 引数を NULL にすることはできません。
E_OUTOFMEMORY
メモリ不足のため、操作を完了できませんでした。
WINBIO_E_INVALID_DEVICE_STATE
Pipeline 引数が指すWINBIO_PIPELINE構造体の StorageContext メンバーが NULL ではないか、StorageHandle メンバーが INVALID_HANDLE_VALUE に設定されていません。

注釈

この関数を実装する場合は、アダプターに必要なすべてのリソースを割り当てて管理し、生体認証ユニット パイプラインにアタッチする必要があります。 これを行うには、プライベート WINIBIO_STORAGE_CONTEXT 構造体をヒープに割り当て、初期化し、パイプライン オブジェクトの StorageContext メンバーにそのアドレスを設定します。

この関数が呼び出されたときに StorageContext フィールドが NULL でない場合、 以前の StorageAdapterDetach の呼び出しによってパイプラインが正しくリセットされず、Windows 生体認証フレームワークに問題を通知するために WINBIO_E_INVALID_DEVICE_STATE を返す必要があります。

同様に、この関数が呼び出されたときに StorageHandle フィールドに INVALID_HANDLE_VALUE が含まれていない場合は、 WINBIO_E_INVALID_DEVICE_STATEを返す必要があります。

この関数で使用されるストレージ アダプター リソースの作成と初期化中にエラーが発生した場合は、戻る前に必要なクリーンアップを実行する必要があります。

次の擬似コードは、この関数の 1 つの可能な実装を示しています。 この例はコンパイルされません。 目的に合わせて調整する必要があります。

/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterAttach
//
// Purpose:
//      Performs any initialization required for later biometric operations.
//
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit performing the operation.
//
static HRESULT
WINAPI
StorageAdapterAttach(
    __inout PWINBIO_PIPELINE Pipeline
    )
{
    HRESULT hr = S_OK;
    PWINBIO_STORAGE_CONTEXT newContext = NULL;

    // Verify that the Pipeline parameter is not NULL.
    if (!ARGUMENT_PRESENT(Pipeline))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    if (Pipeline->StorageContext != NULL ||
        Pipeline->StorageHandle != INVALID_HANDLE_VALUE)
    { 
        // The pipeline state is not valid. This function should never
        // be called if the pipeline already contains a storage context
        // or a valid storage handle.
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Call a custom function (_AdapterAlloc) to allocate memory to hold the 
    // sensor adapter context.
    newContext = (PWINBIO_STORAGE_CONTEXT)_AdapterAlloc(sizeof(WINBIO_STORAGE_CONTEXT));
    if (newContext == NULL)
    {
        hr = E_OUTOFMEMORY;
        goto cleanup;
    }

    // Call a custom function to initialize the result set to be used by the next 
    // query operation. Initialization typically requires that you clear the result set
    // of any previous query, mark the set as empty, and place the result set cursor
    // in a known state.
    // The result set is attached to the storage context so that it can persist from
    // one storage adapter call to the next.  
    hr = _ResultSetInitialize(&newContext->ResultSet);
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // TODO: Initialize any other required context fields (not shown).


    // If initialization completes successfully, attach the context to the 
    // processing pipeline of the biometric unit.
    Pipeline->StorageContext = newContext;
    newContext = NULL;

cleanup:

    if (FAILED(hr) && newContext != NULL)
    {
        _ResultSetCleanup(&newContext->ResultSet);
        _AdapterRelease( newContext );
        newContext = NULL;
    }
    return hr;
}

要件

要件
サポートされている最小のクライアント Windows 7 [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows Server 2008 R2 [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー winbio_adapter.h (Winbio_adapter.h を含む)

こちらもご覧ください

プラグイン関数

StorageAdapterDetach