PIBIO_STORAGE_DETACH_FN回调函数 (winbio_adapter.h)

在从生物识别单元的处理管道中删除存储适配器之前,由 Windows 生物识别框架调用。 此函数的目的是释放附加到管道的适配器特定资源。

语法

PIBIO_STORAGE_DETACH_FN PibioStorageDetachFn;

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

参数

[in, out] Pipeline

指向与执行操作的生物识别单元关联的 WINBIO_PIPELINE 结构的指针。

返回值

如果函数成功,则返回S_OK。 如果函数失败,则必须返回以下 HRESULT 值之一来指示错误。

返回代码 说明
E_POINTER
Pipeline 参数不能为 NULL
WINBIO_E_INVALID_DEVICE_STATE
WINBIO_PIPELINE 结构的 StorageContext 字段不能为 NULL

注解

若要防止内存泄漏,StorageAdapterDetach 函数的实现必须释放管道的 StorageContext 成员指向的专用WINBIO_STORAGE_CONTEXT结构,以及附加到存储上下文的任何其他资源。

如果调用此函数时管道对象中的 StorageContext 字段为 NULL ,则表示管道未正确初始化,必须返回 WINBIO_E_INVALID_DEVICE_STATE 以通知 Windows 生物识别框架问题。

在返回S_OK之前,此函数必须将WINBIO_PIPELINE结构的 StorageContext 字段设置为 NULL,并将 StorageHandle 字段设置为INVALID_HANDLE_VALUE

示例

以下伪代码显示了此函数的一种可能实现。 该示例不编译。 必须根据自己的目的调整它。

/////////////////////////////////////////////////////////////////////////////////////////
//
// StorageAdapterDetach
//
// Purpose:
//      Release adapter specific resources attached to the pipeline.
//
// Parameters:
//      Pipeline -  Pointer to a WINBIO_PIPELINE structure associated with 
//                  the biometric unit performing the operation.
//
static HRESULT
WINAPI
StorageAdapterDetach(
    __inout PWINBIO_PIPELINE Pipeline
    )
{
    HRESULT hr = S_OK;

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

    // Retrieve the context from the pipeline.
    PWINBIO_STORAGE_CONTEXT storageContext = 
           (PWINBIO_STORAGE_CONTEXT)Pipeline->StorageContext;

    // Verify the pipeline state.
    if (storageContext == NULL)
    {
        // The pipeline state is not valid. This function should never
        // be called if the storage context in the pipeline is already
        // closed.
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Release any structures attached to the context block.
    StorageAdapterClearContext(Pipeline);

    // Close the database.
    StorageAdapterCloseDatabase(Pipeline);

    // Remove the context from the pipeline.
    Pipeline->StorageContext = NULL;
    Pipeline->StorageHandle = INVALID_HANDLE_VALUE;

    // Clear the result set. Depending on your implementation, this action
    // can be performed by the StorageAdapterClearContext function called
    // earlier.
    ResultSetCleanup(&storageContext->ResultSet);

    // Release the adapter context.
    _AdapterRelease( storageContext );
    storageContext = NULL;

cleanup:

    return hr;
}

要求

要求
最低受支持的客户端 Windows 7 [仅限桌面应用]
最低受支持的服务器 Windows Server 2008 R2 [仅限桌面应用]
目标平台 Windows
标头 winbio_adapter.h (包括 Winbio_adapter.h)

另请参阅

插件函数

StorageAdapterAttach