다음을 통해 공유


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 반환해야 합니다.

이 함수에서 사용하는 스토리지 어댑터 리소스를 만들고 초기화하는 동안 오류가 발생하는 경우 반환하기 전에 필요한 정리를 수행해야 합니다.

예제

다음 의사 코드는 이 함수의 가능한 구현 중 하나를 보여 줍니다. 예제는 컴파일되지 않습니다. 목적에 맞게 조정해야 합니다.

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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