#ifndef _WINBIO_H
#define _WINBIO_H

#if __POCC__ >= 500
#pragma once
#endif

/* Windows Biometric API definitions (Windows 7) */

#if (NTDDI_VERSION >= NTDDI_WIN7)

#include "winbio_types.h"
#include "winbio_err.h"

#if defined(WIN32_DEFAULT_LIBS)
#pragma comment(lib, "winbio.lib")
#endif

#ifdef __cplusplus
extern "C"{
#endif

typedef VOID (CALLBACK *PWINBIO_VERIFY_CALLBACK)(PVOID, HRESULT, WINBIO_UNIT_ID, BOOLEAN, WINBIO_REJECT_DETAIL);
typedef VOID (CALLBACK *PWINBIO_IDENTIFY_CALLBACK)(PVOID, HRESULT, WINBIO_UNIT_ID, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE, WINBIO_REJECT_DETAIL);
typedef VOID (CALLBACK *PWINBIO_LOCATE_SENSOR_CALLBACK)(PVOID, HRESULT, WINBIO_UNIT_ID);
typedef VOID (CALLBACK *PWINBIO_ENROLL_CAPTURE_CALLBACK)(PVOID, HRESULT, WINBIO_REJECT_DETAIL);
typedef VOID (CALLBACK *PWINBIO_EVENT_CALLBACK)(PVOID, HRESULT, PWINBIO_EVENT);
typedef VOID (CALLBACK *PWINBIO_CAPTURE_CALLBACK)(PVOID, HRESULT, WINBIO_UNIT_ID, PWINBIO_BIR, SIZE_T, WINBIO_REJECT_DETAIL);

#if (NTDDI_VERSION >= NTDDI_WIN8)
typedef enum _WINBIO_ASYNC_NOTIFICATION_METHOD {
    WINBIO_ASYNC_NOTIFY_NONE = 0,
    WINBIO_ASYNC_NOTIFY_CALLBACK,
    WINBIO_ASYNC_NOTIFY_MESSAGE,
    WINBIO_ASYNC_NOTIFY_MAXIMUM_VALUE
} WINBIO_ASYNC_NOTIFICATION_METHOD, *PWINBIO_ASYNC_NOTIFICATION_METHOD;

typedef struct _WINBIO_ASYNC_RESULT {
    WINBIO_SESSION_HANDLE SessionHandle;
    WINBIO_OPERATION_TYPE Operation;
    ULONGLONG SequenceNumber;
    LONGLONG TimeStamp;
    HRESULT ApiStatus;
    WINBIO_UNIT_ID UnitId;
    PVOID UserData;
    union {
        struct {
            BOOLEAN Match;
            WINBIO_REJECT_DETAIL RejectDetail;
        } Verify;
        struct {
            WINBIO_IDENTITY Identity;
            WINBIO_BIOMETRIC_SUBTYPE SubFactor;
            WINBIO_REJECT_DETAIL RejectDetail;
        } Identify;
        struct {
            WINBIO_BIOMETRIC_SUBTYPE SubFactor;
        } EnrollBegin;
        struct {
            WINBIO_REJECT_DETAIL RejectDetail;
        } EnrollCapture;
        struct {
            WINBIO_IDENTITY Identity;
            BOOLEAN IsNewTemplate;
        } EnrollCommit;
        struct {
            WINBIO_IDENTITY Identity;
            SIZE_T SubFactorCount;
            WINBIO_BIOMETRIC_SUBTYPE *SubFactorArray;
        } EnumEnrollments;
        struct {
            PWINBIO_BIR Sample;
            SIZE_T SampleSize;
            WINBIO_REJECT_DETAIL RejectDetail;
        } CaptureSample;
        struct {
            WINBIO_IDENTITY Identity;
            WINBIO_BIOMETRIC_SUBTYPE SubFactor;
        } DeleteTemplate;
        struct {
            WINBIO_PROPERTY_TYPE PropertyType;
            WINBIO_PROPERTY_ID PropertyId;
            WINBIO_IDENTITY Identity;
            WINBIO_BIOMETRIC_SUBTYPE SubFactor;
            SIZE_T PropertyBufferSize;
            PVOID PropertyBuffer;
        } GetProperty;
        struct {
            ULONG None;
        } SetProperty;
        struct {
            WINBIO_EVENT Event;
        } GetEvent;
        struct {
            WINBIO_COMPONENT Component;
            ULONG ControlCode;
            ULONG OperationStatus;
            PUCHAR SendBuffer;
            SIZE_T SendBufferSize;
            PUCHAR ReceiveBuffer;
            SIZE_T ReceiveBufferSize;
            SIZE_T ReceiveDataSize;
        } ControlUnit;
        struct {
            SIZE_T BspCount;
            WINBIO_BSP_SCHEMA *BspSchemaArray;
        } EnumServiceProviders;
        struct {
            SIZE_T UnitCount;
            WINBIO_UNIT_SCHEMA *UnitSchemaArray;
        } EnumBiometricUnits;
        struct {
            SIZE_T StorageCount;
            WINBIO_STORAGE_SCHEMA *StorageSchemaArray;
        } EnumDatabases;
#if (NTDDI_VERSION >= NTDDI_WIN9)
        struct {
            BOOLEAN Match;
            WINBIO_REJECT_DETAIL RejectDetail;
            WINBIO_PROTECTION_TICKET Ticket;
        } VerifyAndReleaseTicket;
        struct {
            WINBIO_IDENTITY Identity;
            WINBIO_BIOMETRIC_SUBTYPE SubFactor;
            WINBIO_REJECT_DETAIL RejectDetail;
            WINBIO_PROTECTION_TICKET Ticket;
        } IdentifyAndReleaseTicket;
#endif /* NTDDI_VERSION >= NTDDI_WIN9 */
    } Parameters;
} WINBIO_ASYNC_RESULT, *PWINBIO_ASYNC_RESULT;

typedef VOID (CALLBACK *PWINBIO_ASYNC_COMPLETION_CALLBACK)(PWINBIO_ASYNC_RESULT);
#endif /* NTDDI_VERSION >= NTDDI_WIN8 */

HRESULT WINAPI WinBioEnumServiceProviders(WINBIO_BIOMETRIC_TYPE, WINBIO_BSP_SCHEMA **, SIZE_T *);
HRESULT WINAPI WinBioEnumBiometricUnits(WINBIO_BIOMETRIC_TYPE, WINBIO_UNIT_SCHEMA **, SIZE_T *);
HRESULT WINAPI WinBioEnumDatabases(WINBIO_BIOMETRIC_TYPE, WINBIO_STORAGE_SCHEMA **, SIZE_T *);
#if (NTDDI_VERSION >= NTDDI_WIN8)
HRESULT WINAPI WinBioAsyncOpenFramework(WINBIO_ASYNC_NOTIFICATION_METHOD, HWND, UINT, PWINBIO_ASYNC_COMPLETION_CALLBACK, PVOID, BOOL, WINBIO_FRAMEWORK_HANDLE *);
HRESULT WINAPI WinBioCloseFramework(WINBIO_FRAMEWORK_HANDLE);
HRESULT WINAPI WinBioAsyncEnumServiceProviders(WINBIO_FRAMEWORK_HANDLE, WINBIO_BIOMETRIC_TYPE);
HRESULT WINAPI WinBioAsyncEnumBiometricUnits(WINBIO_FRAMEWORK_HANDLE, WINBIO_BIOMETRIC_TYPE);
HRESULT WINAPI WinBioAsyncEnumDatabases(WINBIO_FRAMEWORK_HANDLE, WINBIO_BIOMETRIC_TYPE);
HRESULT WINAPI WinBioAsyncMonitorFrameworkChanges(WINBIO_FRAMEWORK_HANDLE, WINBIO_FRAMEWORK_CHANGE_TYPE);
#endif /* NTDDI_VERSION >= NTDDI_WIN8 */
HRESULT WINAPI WinBioOpenSession(WINBIO_BIOMETRIC_TYPE, WINBIO_POOL_TYPE, WINBIO_SESSION_FLAGS, WINBIO_UNIT_ID *, SIZE_T, GUID *, WINBIO_SESSION_HANDLE *);
#if (NTDDI_VERSION >= NTDDI_WIN8)
HRESULT WINAPI WinBioAsyncOpenSession(WINBIO_BIOMETRIC_TYPE, WINBIO_POOL_TYPE, WINBIO_SESSION_FLAGS, WINBIO_UNIT_ID *, SIZE_T, GUID *, WINBIO_ASYNC_NOTIFICATION_METHOD, HWND, UINT, PWINBIO_ASYNC_COMPLETION_CALLBACK, PVOID, BOOL, WINBIO_SESSION_HANDLE *);
#endif /* NTDDI_VERSION >= NTDDI_WIN8 */
HRESULT WINAPI WinBioCloseSession(WINBIO_SESSION_HANDLE);
HRESULT WINAPI WinBioVerify(WINBIO_SESSION_HANDLE, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE, WINBIO_UNIT_ID *, BOOLEAN *, WINBIO_REJECT_DETAIL *);
HRESULT WINAPI WinBioVerifyWithCallback(WINBIO_SESSION_HANDLE, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE, PWINBIO_VERIFY_CALLBACK, PVOID);
HRESULT WINAPI WinBioIdentify(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID *, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE *, WINBIO_REJECT_DETAIL *);
HRESULT WINAPI WinBioIdentifyWithCallback(WINBIO_SESSION_HANDLE, PWINBIO_IDENTIFY_CALLBACK, PVOID);
HRESULT WINAPI WinBioWait(WINBIO_SESSION_HANDLE);
HRESULT WINAPI WinBioCancel(WINBIO_SESSION_HANDLE);
HRESULT WINAPI WinBioLocateSensor(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID *);
HRESULT WINAPI WinBioLocateSensorWithCallback(WINBIO_SESSION_HANDLE, PWINBIO_LOCATE_SENSOR_CALLBACK, PVOID);
HRESULT WINAPI WinBioEnrollBegin(WINBIO_SESSION_HANDLE, WINBIO_BIOMETRIC_SUBTYPE, WINBIO_UNIT_ID);
HRESULT WINAPI WinBioEnrollCapture(WINBIO_SESSION_HANDLE, WINBIO_REJECT_DETAIL *);
HRESULT WINAPI WinBioEnrollCaptureWithCallback(WINBIO_SESSION_HANDLE, PWINBIO_ENROLL_CAPTURE_CALLBACK, PVOID);
HRESULT WINAPI WinBioEnrollCommit(WINBIO_SESSION_HANDLE, WINBIO_IDENTITY *, BOOLEAN *);
HRESULT WINAPI WinBioEnrollDiscard(WINBIO_SESSION_HANDLE);
HRESULT WINAPI WinBioEnumEnrollments(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE **, SIZE_T *);
HRESULT WINAPI WinBioRegisterEventMonitor(WINBIO_SESSION_HANDLE, WINBIO_EVENT_TYPE, PWINBIO_EVENT_CALLBACK, PVOID);
HRESULT WINAPI WinBioUnregisterEventMonitor(WINBIO_SESSION_HANDLE);
HRESULT WINAPI WinBioCaptureSample(WINBIO_SESSION_HANDLE, WINBIO_BIR_PURPOSE, WINBIO_BIR_DATA_FLAGS, WINBIO_UNIT_ID *, PWINBIO_BIR *, SIZE_T *, WINBIO_REJECT_DETAIL *);
HRESULT WINAPI WinBioCaptureSampleWithCallback(WINBIO_SESSION_HANDLE, WINBIO_BIR_PURPOSE, WINBIO_BIR_DATA_FLAGS, PWINBIO_CAPTURE_CALLBACK, PVOID);
HRESULT WINAPI WinBioDeleteTemplate(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE);
HRESULT WINAPI WinBioLockUnit(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID);
HRESULT WINAPI WinBioUnlockUnit(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID);
HRESULT WINAPI WinBioControlUnit(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID, WINBIO_COMPONENT, ULONG, PUCHAR, SIZE_T, PUCHAR, SIZE_T, SIZE_T *, ULONG *);
HRESULT WINAPI WinBioControlUnitPrivileged(WINBIO_SESSION_HANDLE, WINBIO_UNIT_ID, WINBIO_COMPONENT, ULONG, PUCHAR, SIZE_T, PUCHAR, SIZE_T, SIZE_T *, ULONG *);
HRESULT WINAPI WinBioGetProperty(WINBIO_SESSION_HANDLE, WINBIO_PROPERTY_TYPE, WINBIO_PROPERTY_ID, WINBIO_UNIT_ID, WINBIO_IDENTITY *, WINBIO_BIOMETRIC_SUBTYPE, PVOID *, SIZE_T *);
HRESULT WINAPI WinBioFree(PVOID);
HRESULT WINAPI WinBioSetCredential(WINBIO_CREDENTIAL_TYPE, PUCHAR, SIZE_T, WINBIO_CREDENTIAL_FORMAT);
HRESULT WINAPI WinBioRemoveCredential(WINBIO_IDENTITY, WINBIO_CREDENTIAL_TYPE);
HRESULT WINAPI WinBioRemoveAllCredentials(void);
HRESULT WINAPI WinBioRemoveAllDomainCredentials(void);
HRESULT WINAPI WinBioGetCredentialState(WINBIO_IDENTITY, WINBIO_CREDENTIAL_TYPE, WINBIO_CREDENTIAL_STATE *);
HRESULT WINAPI WinBioLogonIdentifiedUser(WINBIO_SESSION_HANDLE);
VOID WINAPI WinBioGetEnabledSetting(BOOLEAN *, PWINBIO_SETTING_SOURCE_TYPE);
VOID WINAPI WinBioGetLogonSetting(BOOLEAN *, PWINBIO_SETTING_SOURCE_TYPE);
VOID WINAPI WinBioGetDomainLogonSetting(BOOLEAN *, PWINBIO_SETTING_SOURCE_TYPE);
HRESULT WINAPI WinBioAcquireFocus(void);
HRESULT WINAPI WinBioReleaseFocus(void);

#ifdef __cplusplus
}
#endif

#endif /* NTDDI_VERSION >= NTDDI_WIN7 */

#endif /* _WINBIO_H */
