Bagikan melalui


fungsi panggilan balik PIBIO_STORAGE_DETACH_FN (winbio_adapter.h)

Dipanggil oleh Windows Biometric Framework segera sebelum adaptor penyimpanan dihapus dari alur pemrosesan unit biometrik. Tujuan dari fungsi ini adalah untuk merilis sumber daya spesifik adaptor yang melekat pada alur.

Sintaks

PIBIO_STORAGE_DETACH_FN PibioStorageDetachFn;

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

Parameter

[in, out] Pipeline

Penunjuk ke struktur WINBIO_PIPELINE yang terkait dengan unit biometrik yang melakukan operasi.

Mengembalikan nilai

Jika fungsi berhasil, fungsi akan mengembalikan S_OK. Jika fungsi gagal, fungsi harus mengembalikan salah satu nilai HRESULT berikut untuk menunjukkan kesalahan.

Menampilkan kode Deskripsi
E_POINTER
Parameter Alur tidak boleh NULL.
WINBIO_E_INVALID_DEVICE_STATE
Bidang StorageContext dari struktur WINBIO_PIPELINE tidak boleh NULL.

Keterangan

Untuk mencegah kebocoran memori, implementasi fungsi StorageAdapterDetach Anda harus merilis struktur WINBIO_STORAGE_CONTEXT privat yang ditunjukkan oleh anggota StorageContext dari alur bersama dengan sumber daya lain yang melekat pada konteks penyimpanan.

Jika bidang StorageContext di objek alur adalah NULL ketika fungsi ini dipanggil, alur tidak diinisialisasi dengan benar dan Anda harus mengembalikan WINBIO_E_INVALID_DEVICE_STATE untuk memberi tahu Windows Biometric Framework tentang masalah tersebut.

Sebelum mengembalikan S_OK, fungsi ini harus mengatur bidang StorageContext dari struktur WINBIO_PIPELINE ke NULL dan bidang StorageHandle ke INVALID_HANDLE_VALUE.

Contoh

Pseudocode berikut menunjukkan salah satu kemungkinan implementasi fungsi ini. Contoh tidak dikompilasi. Kau harus menyesuaikannya sesuai dengan tujuanmu.

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

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung Windows 7 [hanya aplikasi desktop]
Server minimum yang didukung Windows Server 2008 R2 [hanya aplikasi desktop]
Target Platform Windows
Header winbio_adapter.h (termasuk Winbio_adapter.h)

Lihat juga

Fungsi Plug-in

StorageAdapterAttach