//-------------------------------------------------------------------------//
// ReaderDll  v2.00.0032 head file
//-------------------------------------------------------------------------//
#include <windows.h>

//-------------------------------------------------------------------------//
#define    ID_MOD_1D                   1    // 1D normal
#define    ID_MOD_1D_ELR               2    // 1D Long Laser
#define    ID_MOD_2D                   4    // 2D
#define    ID_MOD_TI_RFID              16   // Texas Instrument RFID
#define    ID_MOD_RFID                 32   // RFID

//-------------------------------------------------------------------------//
#define    DC_READER_BC                7    // barcode reader
#define    DC_READER_RFID              32   // RFID reader
#define    ALL_DEVICE                  255  // all device

//-------------------------------------------------------------------------//
#define    CMD_MAXLEN                  1024
#define    DATA_MAXLEN                 4096

//-------------------------------------------------------------------------//
#define    READ_UID                    1
#define    READ_DATA                   2

//-------------------------------------------------------------------------//
// error code
#define    W_READER_ALREADY_INIT       -51 

#define    E_READER_NOT_INIT           -101
#define    E_READER_INIT_FAILED        -102
#define    E_READER_BC_RESET_FAILED    -111
#define    E_READER_RFID_RESET_FAILED  -112
#define    E_READER_RESET_FAILED       -113
#define    E_READER_GET_PARAM_FAILED   -121
#define    E_READER_SET_PARAM_FAILED   -122
#define    E_READER_NO_SPEC_DC_BC      -131
#define    E_READER_NO_SPEC_DC_RFID    -132
#define    E_READER_NO_SPEC_DC         -133
#define    E_SOUND_INVALID_INDEX       -241
#define    E_SOUND_INVALID_PATH        -242
#define    E_SOUND_PALY_FAILED         -243
#define    E_VIBRATOR_INVALID_MODE     -251
#define    E_VIBRATOR_INVALID_DURATION -252

#define    E_TAG_READ_FAILED           -272
#define    E_TAG_VALUE_OVER_RANGE      -273
#define    E_TAG_INVALID_LENGTH        -274
#define    E_TAG_GET_DATA_FAILED       -275
#define    E_TAG_WRITE_FAILED          -276
#define    E_TAG_CANNOT_WRITE          -277
#define    E_TAG_NO_TAG                -278
#define    E_TAG_WRITE_TIMEOUT         -279
#define    E_TAG_CANNOT_READ           -280
#define    E_TAG_READ_TIMEOUT          -281

#define    E_BUFF_IS_TOO_SMALL         -300

//-------------------------------------------------------------------------//
#define    DECODE_IMAGE                TEXT("WM_DECODEIMAGE")
#define    DECODE_BC                   TEXT("DecodeEventBC")
#define    DECODE_RFID                 TEXT("DecodeEventRFID")
#define    DECODE_MSG                  TEXT("WM_DECODEDATA")

typedef struct tagCode39 
{
    BYTE    Enabled;    
    BYTE    SendStartStop;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    FullASCII;
} CODE39;


typedef struct tagItalyPharma 
{
    BYTE    Enabled;
    BYTE    SendChecksum;
} ITPHARMA;


typedef struct tagFrenchPharma 
{
    BYTE    Enabled;
    BYTE    SendChecksum;
} FRPHARMA;


typedef struct tagIndustrial25 
{
    BYTE    Enabled;
    BYTE    SelStartStop;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    LenFormat;
    BYTE    LenParam1;
    BYTE    LenParam2;
} INDUST25;


typedef struct tagInterleave25 
{
    BYTE    Enabled;
    BYTE    SelStartStop;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    LenFormat;
    BYTE    LenParam1;
    BYTE    LenParam2;
} INTER25;


typedef struct tagMatrix25 
{
    BYTE    Enabled;
    BYTE    SelStartStop;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    LenFormat;
    BYTE    LenParam1;
    BYTE    LenParam2;
} MATRIX25;


typedef struct tagCodabar 
{
    BYTE    Enabled;
    BYTE    SelStartStop;
} CODABAR;


typedef struct tagMSI 
{
    BYTE    Enabled;
    BYTE    SelVerifyChecksum;
    BYTE    SelSendCheckSum;
    BYTE    LenFormat;
    BYTE    LenParam1;
    BYTE    LenParam2;
} MSI;


typedef struct tagPlessey 
{
    BYTE    Enabled;
    BYTE    ConvertToUK;
    BYTE    SendChecksum;
} PLESSEY;


typedef struct tagUPCE 
{
    BYTE    Enabled;
    BYTE    ConvertToUPCA;
    BYTE    SendSysNumber;
    BYTE    SendChecksum;
    BYTE    UseAddon2;
    BYTE    UseAddon5;
} UPCE;


typedef struct tagEAN8
{
    BYTE    Enabled;
    BYTE    SendChecksum;
    BYTE    UseAddon2;
    BYTE    UseAddon5;
    BYTE    ConvertToEAN13;
} EAN8;


typedef struct tagEAN13 
{
    BYTE    Enabled;
    BYTE    ISBNConversion;
    BYTE    ISSNConversion;
    BYTE    SendChecksum;
    BYTE    UseAddon2;
    BYTE    UseAddon5;
    BYTE    SendUPCAsysNumber;
    BYTE    SendUPCAchecksum;
    BYTE    ConvUPCAtoEAN13;
} EAN13;


typedef struct tagTelepen 
{
    BYTE    Enabled;
    BYTE    Format;
} TELEPEN;


typedef struct tagRSS14
{
    BYTE    Enabled;
    BYTE    SendChecksum;
    BYTE    SendAppID;
    BYTE    SendCodeID;
} RSS14;


typedef struct tagRSS14Lim
{
    BYTE    Enabled;
    BYTE    SendChecksum;
    BYTE    SendAppID;
    BYTE    SendCodeID;
} RSS14LIM;


typedef struct tagRSS14Exp
{
    BYTE    Enabled;
    BYTE    SendCodeID;
} RSS14EXP;


typedef struct tagCode93
{
    BYTE    Enabled;
} CODE93;


typedef struct tagCode128
{
    BYTE    Enabled;
} CODE128;


typedef struct tagEAN128
{
    BYTE    Enabled;
    BYTE    SendCodeID;
} EAN128;


typedef struct tagBarcode
{
    CODE39      bcCode39;
    ITPHARMA    bcItPharma;
    FRPHARMA    bcFrPharma;
    INDUST25    bcIndust25;
    INTER25     bcInter25;
    MATRIX25    bcMatrix25;
    CODABAR     bcCodabar;
    MSI         bcMSI;
    PLESSEY     bcPlessey;
    UPCE        bcUPCE;
    EAN8        bcEAN8;
    EAN13       bcEAN13;
    TELEPEN     bcTelepen;
    RSS14       bcRSS14;
    RSS14LIM    bcRSS14Lim;
    RSS14EXP    bcRSS14Exp;
    CODE93      bcCode93;
    CODE128     bcCode128;
    EAN128      bcEAN128;

    BYTE        gsScanMode;
    BYTE        gsTimeOut;
    BYTE        gsReadRedundancy;
    BYTE        gsNegativeBC;
    BYTE        gsGtin;
    BYTE        Reserve [18];
} BARCODE, *LPBARCODE;


typedef struct tagUPCEAN
{
    BYTE    EnaUPCA;
    BYTE    EnaUPCE;
    BYTE    EnaUPCE1;
    BYTE    EnaEAN8;
    BYTE    EnaEAN13;
    BYTE    EnaBooklandEAN;
    BYTE    UseAddon;
    BYTE    AddonScanRedundancy;
    BYTE    SendChecksumUPCA;
    BYTE    SendChecksumUPCE;
    BYTE    SendChecksumUPCE1;
    BYTE    PreambleUPCA;
    BYTE    PreambleUPCE;
    BYTE    PreambleUPCE1;
    BYTE    ConvertUPCEToA;
    BYTE    ConvertUPCE1ToA;
    BYTE    ConvertEAN8To13;
    BYTE    UCCCouponExtCode;
    BYTE    LinearUPCDecode;
} UPCEANS;


typedef struct tagCode128S 
{
    BYTE    EnaCode128;
    BYTE    EnaEAN128;
    BYTE    EnaISBT128;
} CODE128S;


typedef struct tagCode39S 
{
    BYTE    EnaCode39;
    BYTE    EnaTriopticCode39;
    BYTE    ConvertCode39To32;
    BYTE    Code32Prefix;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    FullASCII;
} CODE39S;

typedef struct tagCode93S 
{
    BYTE    EnaCode93;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
} CODE93S;


typedef struct tagCode11S
{
    BYTE    EnaCode11;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
} CODE11S;


typedef struct tagInterleave25S
{
    BYTE    EnaITF25;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
    BYTE    VerifyCheck;
    BYTE    SendChecksum;
    BYTE    ConvertITF25ToEAN13;
} INTER25S;


typedef struct tagIndustrial25S
{
    BYTE    EnaDTF25;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
} INDUST25S;


typedef struct tagCodabarS
{
    BYTE    EnaCodabar;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
    BYTE    CLSIEdit;
    BYTE    NOTISEdit;
} CODABARS;


typedef struct tagMSIS
{
    BYTE    EnaMSI;
    BYTE    SetLenType;
    BYTE    MinLen;
    BYTE    MaxLen;
    BYTE    CheckDigit;
    BYTE    SendChecksum;
    BYTE    ChecksumAlgorithm;
} MSIS;



typedef struct tagPostalCode
{
    BYTE    EnaUSPost;
    BYTE    EnaUSPlanet;
    BYTE    EnaUKPost;
    BYTE    SendChecksumUK;
    BYTE    EnaJPPost;
    BYTE    EnaAUPost;
    BYTE    EnaDUPost;
    BYTE    SendChecksumUS;
} POSTALCODE;


typedef struct tagRSS14S
{
    BYTE    EnaRSS;
    BYTE    EnaRSSLim;
    BYTE    EnaRSSExp;
    BYTE    ConvertRSSToEAN;
} RSS14S;



typedef struct tagComposite
{
    BYTE    EnaCompCCC;
    BYTE    EnaCompCCAB;
    BYTE    EnaCompTLC39;
    BYTE    UPCCompMode;
    BYTE    EnaCompEmu;
} COMPOSITE;


typedef struct tagSymbologies
{
    BYTE    EnaPDF417;
    BYTE    EnaMicPDF417;
    BYTE    EnaCode128Emu;
    BYTE    EnaDataMatrix;
    BYTE    EnaMaxiCode;
    BYTE    EnaQRCode;
} SYMBOLOGIES;



typedef struct tagMacroPDF
{
    BYTE    DecodeMode;
    BYTE    SendHeader;
    BYTE    EscCharacters;
} MACROPDF;



typedef struct tagBarcode1DSym
{
    UPCEANS        bcUPCEAN;
    CODE128S       bcCode128;
    CODE39S        bcCode39;
    CODE93S        bcCode93;
    INTER25S       bcInter25;
    INDUST25S      bcIndust25;
    CODABARS       bcCodabar;
    MSIS           bcMSI;
    RSS14S         bcRSS14;
    BYTE           gsDecodeTimeout;
    BYTE           gsSameTimeout;
    BYTE           gsAimDuration;
    BYTE           gsTransmitCodeIdChar;
    BYTE           Reserve [22];
} BARCODESYM, *LPBARCODESYM;



typedef struct Symbol2dImage 
{
     BYTE          gsEnableImageCapture;
     BYTE          gsEnableWaitCursor;
     BYTE          gsImageAutoexposure;
     BYTE          gsImageIllumination;
     BYTE          gsGain;
     BYTE          gsExposureTime;
     BYTE          gsSnapshotAimPattern;
     BYTE          gsImageResolution;
     BYTE          gsJpgImageOptions;
     BYTE          gsQualityValue;
     BYTE          gsJpgSizeValue;
     BYTE          gsImageFileFormat;
     BYTE          gsBitsPerPixel;
} IMAGE2D;



typedef struct tagBarcode2D
{
    UPCEANS        bcUPCEAN;
    CODE128S       bcCode128;
    CODE39S        bcCode39;
    CODE93S        bcCode93;
    CODE11S        bcCode11;
    INTER25S       bcInter25;
    INDUST25S      bcIndust25;
    CODABARS       bcCodabar;
    MSIS           bcMSI;
    POSTALCODE     bcPostalCode;
    RSS14S         bcRSS14;
    COMPOSITE      bcComposite;
    SYMBOLOGIES    bcSymbologies;
    MACROPDF       bcMacroPDF;

    BYTE           gsDecodeTimeout;
    BYTE           gsSameTimeout;
    BYTE           gsAutoexposure;
    BYTE           gsIllumination;
    BYTE           gsAimPattern;
    BYTE           gsImageFocus;
    BYTE           gsLedIllumination;
    BYTE           gsTransmitCodeIdChar;
                                            
    IMAGE2D        image2D;                                            
    BYTE           Reserve [7];
} BARCODE2D, *LPBARCODE2D;


typedef struct tagSettingsRFID
{
    BYTE    gsReadUID;
    BYTE    gsReadData;
    BYTE    gsUseDelim;
    BYTE    gsDelimChar [4];
    BYTE    gsReadStart;
    BYTE    gsReadLen;
    BYTE    gsReadTimeout;
    BYTE    gsLoginKey [15];
    BYTE    Reserve [5];
} GSETRFID, *LPGSETRFID;


typedef struct tagReaderParam
{
    BYTE          CtrlDCtype;
    BARCODE       bcBC;
    BARCODESYM    bcBCSym;
    BARCODE2D     bcBC2D;
    GSETRFID      GSetRFID;

    BYTE          gsActiveDC;
    BYTE          gsGoodRead;
    BYTE          gsWarningBeep;  //(obsolete)
    BYTE          gsEnaVibrator;
    BYTE          gsVibraDuration;
    BYTE          gsSendDecodeData;
    BYTE          gsAutoEnterWay;
    BYTE          gsAutoEnterChar;
    BYTE          gsPrefixCode [11];
    BYTE          gsSuffixCode [11];
    BYTE          gsShowCodeType;
    BYTE          gsShowCodeLen;
                                            
    BYTE          gsGoodReadLedDuration;
    BYTE          gsBuzzerDuration;
    BYTE          gsBuzzerFreq;

    BYTE          Reserve [25];
} READERPARAM, *LPREADERPARAM;



typedef  INT (CALLBACK *INITREADER)(VOID);
typedef  INT (CALLBACK *HALTREADER)(INT nRdrType);
typedef  INT (CALLBACK *GETREADERTYPE)(VOID);
typedef  INT (CALLBACK *GETTRIGGERKEYSTATUS)(VOID);
typedef  INT (CALLBACK *SETTRIGGERKEY)(BOOL bEnable);
typedef  INT (CALLBACK *GETACTIVEDEVICE)(VOID);
typedef  INT (CALLBACK *SETACTIVEDEVICE)(INT nActDC);
typedef  INT (CALLBACK *GETREADERSETTINGS)(READERPARAM *pParam);
typedef  INT (CALLBACK *SETREADERSETTINGS)(CONST READERPARAM *pParam);
typedef  INT (CALLBACK *GETSERIALNUMBER)(BYTE *lpBuf, INT nBufSize);
typedef  INT (CALLBACK *GETDECODEDATA)(BYTE *lpBuf, INT nBufSize);
typedef  INT (CALLBACK *GETDECODETYPE)(VOID);
typedef  INT (CALLBACK *GETDECODERFIDDATA)(BYTE *lpBuf, INT nBufSize);
typedef  INT (CALLBACK *GETDECODERFIDUID)(BYTE *lpBuf, INT nBufSize);
typedef  INT (CALLBACK *RESETREADERTODEFAULT)(INT nRdrType);
typedef  INT (CALLBACK *GETOUTPUTRECORD)(INT nRdrType, BYTE *lpBuf, INT nBufSize);
typedef  INT (CALLBACK *GETDECODETAGTYPE)(VOID);
typedef  INT (CALLBACK *GETDLLDEFAULTSETTINGS)(READERPARAM *pParam);
typedef  INT (CALLBACK *WRITERFIDDATA)(BYTE *pszWriteData, INT nStartPage, INT nWriteLen, INT *nWritten, INT nTimeout, INT nMode, CHAR *loginKey);
typedef  INT (CALLBACK *READRFIDDATA)(INT nType, BYTE *pszReadData, INT nBufSize, INT nStartPage, INT nReadLen, INT nTimeout, CHAR *loginKey);
typedef  INT (CALLBACK *BEEPER)(INT nMode, BYTE *lpszPath);
typedef  INT (CALLBACK *SETVIBRATOR)(INT nMode, INT nDuration);
typedef  INT (CALLBACK *GETDLLVER)(CHAR *buf, INT bufSize);
typedef  INT (CALLBACK *INITREADEREX)(VOID);
typedef  INT (CALLBACK *GETIMAGESIZE)(VOID);
typedef  INT (CALLBACK *GETIMAGECONTENT)(BYTE *buf, INT bufSize);
typedef  INT (CALLBACK *READIMAGE)(BYTE *buf, INT bufSize, INT *capturedImgSize);


      