#ifdef IDREADERDLL_EXPORTS
#define IDREADERDLL_API __declspec(dllexport)
#else
#define IDREADERDLL_API //__declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif 

	IDREADERDLL_API int WINAPI InitComm(int port);
	IDREADERDLL_API int WINAPI CloseComm();

	IDREADERDLL_API int WINAPI Authenticate();
	IDREADERDLL_API int WINAPI Read_Content(int active);
	IDREADERDLL_API int WINAPI Read_Content_Path(char* cPath, int active);
	IDREADERDLL_API int WINAPI GetSAMID(char *samid);
	IDREADERDLL_API int WINAPI GetCOMBaud(unsigned int *puiBaud);
	IDREADERDLL_API int WINAPI SetCOMBaud(unsigned int  uiCurrBaud, unsigned int  uiSetBaud);

	IDREADERDLL_API BOOL WINAPI MakeIDCardImage(LPSTR sHead, LPSTR sIDCardImage);	
	IDREADERDLL_API BOOL WINAPI MakeIDCardImages(LPSTR sHead, LPSTR sIDCardImageFace, LPSTR sIDCardImageBack);
	IDREADERDLL_API int WINAPI SetAntPower(int PowerOn);
	IDREADERDLL_API int WINAPI Buzzer(unsigned char beepTime, unsigned char waitTime, unsigned char beepCount);
	IDREADERDLL_API int WINAPI ActivateCard(int nReaderSlot, unsigned char *pRecvDatas, int *nRecvLen);

	IDREADERDLL_API LPSTR WINAPI GetName(VOID);
	IDREADERDLL_API BOOL WINAPI GetName2(LPBYTE sName, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetSex(VOID);
	IDREADERDLL_API BOOL WINAPI GetSex2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetSexCode(VOID);
	IDREADERDLL_API BOOL WINAPI GetSexCode2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetNation(VOID);
	IDREADERDLL_API BOOL WINAPI GetNation2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetNationCode(VOID);
	IDREADERDLL_API BOOL WINAPI GetNationCode2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetBornDate(VOID);
	IDREADERDLL_API BOOL WINAPI GetBornDate2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetAddress(VOID);
	IDREADERDLL_API BOOL WINAPI GetAddress2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetIDNo(VOID);
	IDREADERDLL_API BOOL WINAPI GetIDNo2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetSignGov(VOID);
	IDREADERDLL_API BOOL WINAPI GetSignGov2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetStartDate(VOID);
	IDREADERDLL_API BOOL WINAPI GetStartDate2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetEndDate(VOID);
	IDREADERDLL_API BOOL WINAPI GetEndDate2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API LPSTR WINAPI GetNewAddress(VOID);
	IDREADERDLL_API BOOL WINAPI GetNewAddress2(LPBYTE sTmp, LPINT nLen);

	IDREADERDLL_API BOOL WINAPI GetPhoto(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API BOOL WINAPI GetFingerPrint(LPBYTE sTmp, LPINT nLen);

	//---------------------------------------------------------------------------
	//外国人永久居住证相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API LPSTR WINAPI GetFPR_ENName();	//英文姓名
	IDREADERDLL_API BOOL WINAPI GetFPR_ENName2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_SEX();			//性别
	IDREADERDLL_API BOOL WINAPI GetFPR_SEX2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_IDNo();		//永久居留证号码
	IDREADERDLL_API BOOL WINAPI GetFPR_IDNo2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_NationCode();//国籍或所在地区代码
	IDREADERDLL_API BOOL WINAPI GetFPR_NationCode2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_Nation();//国籍或所在地区
	IDREADERDLL_API BOOL WINAPI GetFPR_Nation2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_CHNName();//中文姓名
	IDREADERDLL_API BOOL WINAPI GetFPR_CHNName2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_ValidStartDate();//证件签发日期
	IDREADERDLL_API BOOL WINAPI GetFPR_ValidStartDate2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_ValidEndDate();//证件终止日期
	IDREADERDLL_API BOOL WINAPI GetFPR_ValidEndDate2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_Birthday();//出生日期
	IDREADERDLL_API BOOL WINAPI GetFPR_Birthday2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_IDVersion();//证件版本号
	IDREADERDLL_API BOOL WINAPI GetFPR_IDVersion2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_IssuingAuthorityCode();//当次申请受理机关代码
	IDREADERDLL_API BOOL WINAPI GetFPR_IssuingAuthorityCode2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_IDType();//证件类型标识,大写字母I
	IDREADERDLL_API BOOL WINAPI GetFPR_IDType2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetFPR_Reserve();//预留
	IDREADERDLL_API BOOL WINAPI GetFPR_Reserve2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API INT WINAPI IsFPRIDCard();//是否外国人永久居留证
	IDREADERDLL_API VOID WINAPI DeleteMBCSString(LPSTR str);
	//---------------------------------------------------------------------------
	//新版外国人永久居住证相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API LPSTR WINAPI GetFPR2_CHNName();//中文姓名
	IDREADERDLL_API LPSTR WINAPI GetFPR2_SexCode();//性别代码
	IDREADERDLL_API LPSTR WINAPI GetFPR2_RenewalTimes();//换证次数
	IDREADERDLL_API LPSTR WINAPI GetFPR2_Birthday();//出生日期	
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ENName();//英文姓名	
	IDREADERDLL_API LPSTR WINAPI GetFPR2_IDNo();//永久居留证身份证号码
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ReserveA();//预留
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ValidStartDate();//有效起始日期
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ValidEndDate();//有效截止日期
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ENNameB();//英文姓名备用
	IDREADERDLL_API LPSTR WINAPI GetFPR2_NationCode();//国籍
	IDREADERDLL_API LPSTR WINAPI GetFPR2_Nation();
	IDREADERDLL_API LPSTR WINAPI GetFPR2_IDType();//证件类型标识 'Y'
	IDREADERDLL_API LPSTR WINAPI GetFPR2_ReserveB();//既往版本证件号码关联项
	IDREADERDLL_API LPSTR WINAPI GetFPR2_Sex();//性别

	IDREADERDLL_API BOOL WINAPI GetFPR2_CHNName2(LPBYTE sTmp, LPINT nLen);//中文姓名
	IDREADERDLL_API BOOL WINAPI GetFPR2_SexCode2(LPBYTE sTmp, LPINT nLen);//性别代码
	IDREADERDLL_API BOOL WINAPI GetFPR2_RenewalTimes2(LPBYTE sTmp, LPINT nLen);//换证次数
	IDREADERDLL_API BOOL WINAPI GetFPR2_Birthday2(LPBYTE sTmp, LPINT nLen);//出生日期	
	IDREADERDLL_API BOOL WINAPI GetFPR2_ENName2(LPBYTE sTmp, LPINT nLen);//英文姓名	
	IDREADERDLL_API BOOL WINAPI GetFPR2_IDNo2(LPBYTE sTmp, LPINT nLen);//永久居留证身份证号码
	IDREADERDLL_API BOOL WINAPI GetFPR2_ReserveA2(LPBYTE sTmp, LPINT nLen);//预留
	IDREADERDLL_API BOOL WINAPI GetFPR2_ValidStartDate2(LPBYTE sTmp, LPINT nLen);//有效起始日期
	IDREADERDLL_API BOOL WINAPI GetFPR2_ValidEndDate2(LPBYTE sTmp, LPINT nLen);//有效截止日期
	IDREADERDLL_API BOOL WINAPI GetFPR2_ENNameB2(LPBYTE sTmp, LPINT nLen);//英文姓名备用
	IDREADERDLL_API BOOL WINAPI GetFPR2_NationCode2(LPBYTE sTmp, LPINT nLen);//国籍
	IDREADERDLL_API BOOL WINAPI GetFPR2_Nation2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API BOOL WINAPI GetFPR2_IDType2(LPBYTE sTmp, LPINT nLen);//证件类型标识 'Y'
	IDREADERDLL_API BOOL WINAPI GetFPR2_ReserveB2(LPBYTE sTmp, LPINT nLen);//既往版本证件号码关联项
	IDREADERDLL_API BOOL WINAPI GetFPR2_Sex2(LPBYTE sTmp, LPINT nLen);//性别

	IDREADERDLL_API INT WINAPI IsFPR2IDCard();//是否外国人永久居留证
	//---------------------------------------------------------------------------
	//港澳台居民居住证相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API INT WINAPI IsGATIDCard();//是否港澳台居民居住证
	IDREADERDLL_API LPSTR WINAPI GetGAT_Name();	//姓名(30B)
	IDREADERDLL_API BOOL WINAPI GetGAT_Name2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_SEX();			//性别
	IDREADERDLL_API BOOL WINAPI GetGAT_SEX2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_SEXCode();			//性别代码(2B)
	IDREADERDLL_API BOOL WINAPI GetGAT_SEXCode2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_ReserveA();//预留(4B)
	IDREADERDLL_API BOOL WINAPI GetGAT_ReserveA2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_Birthday();//出生日期(16B)
	IDREADERDLL_API BOOL WINAPI GetGAT_Birthday2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_Address();//详细地址(70B)
	IDREADERDLL_API BOOL WINAPI GetGAT_Address2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_IDNo();		//公民身份证号码(36B)
	IDREADERDLL_API BOOL WINAPI GetGAT_IDNo2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_IssuingAuthority();//签发机关(30B);
	IDREADERDLL_API BOOL WINAPI GetGAT_IssuingAuthority2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_ValidStartDate();//有效起始日期
	IDREADERDLL_API BOOL WINAPI GetGAT_ValidStartDate2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_ValidEndDate();//有效截至日期(16B)
	IDREADERDLL_API BOOL WINAPI GetGAT_ValidEndDate2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_PassportNo();//通行证号码(18B)
	IDREADERDLL_API BOOL WINAPI GetGAT_PassportNo2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_IssuanceCount();//签发次数(4B)
	IDREADERDLL_API BOOL WINAPI GetGAT_IssuanceCount2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_ReserveB();//预留(6B)
	IDREADERDLL_API BOOL WINAPI GetGAT_ReserveB2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_IDType();//证件类型标识(2B),大写字母J
	IDREADERDLL_API BOOL WINAPI  GetGAT_IDType2(LPBYTE sTmp, LPINT nLen);
	IDREADERDLL_API LPSTR WINAPI GetGAT_ReserveC();//预留(6B)
	IDREADERDLL_API BOOL WINAPI GetGAT_ReserveC2(LPBYTE sTmp, LPINT nLen);

	//---------------------------------------------------------------------------
	//ISO15693标签相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API int WINAPI ISO15693_ReadSingleBlock(bool readSecSta, int nBlkAddr, unsigned char bufBlockDat[], int nSize, int *bytesBlkDatRead);
	IDREADERDLL_API int WINAPI ISO15693_WriteSingleBlock(int blkAddr, unsigned char newBlkData[], int bytesToWrite);
	IDREADERDLL_API int WINAPI ISO15693_ReadMultiBlocks(bool readSecSta, int nBlkAddr, int numOfBlksToRead, int *numOfBlksRead, unsigned char bufBlockDat[], int nSize, int *bytesBlkDatRead);
	IDREADERDLL_API int WINAPI ISO15693_WriteMultipleBlocks(int blkAddr, int numOfBlks, unsigned char newBlkData[], int bytesToWrite);
	IDREADERDLL_API int WINAPI ISO15693_GetBlockSecStatus(int blkAddr, int numOfBlks, unsigned char bufBlkSecs[], int nSize, int *bytesSecRead);
	IDREADERDLL_API int WINAPI ISO15693_GetSystemInfo(unsigned char uid[], unsigned char *dsfid, unsigned char *afi, int *blkSize, int *numOfBloks, unsigned char* icRef);
	IDREADERDLL_API int WINAPI ISO15693_LockMultipleBlocks(int blkAddr, int numOfBlks);
	IDREADERDLL_API int WINAPI ISO15693_WriteAFI(unsigned char afi);
	IDREADERDLL_API int WINAPI ISO15693_LockAFI();
	IDREADERDLL_API int WINAPI ISO15693_WriteDSFID(unsigned char dsfid);
	IDREADERDLL_API int WINAPI ISO15693_LockDSFID();
	IDREADERDLL_API int WINAPI ISO15693_Inventory(unsigned char afi, unsigned char bufUids[], int nSize, int *bytesUidNums);

	//---------------------------------------------------------------------------
	//ISO7816相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API int WINAPI ISO7816_CardInsert(int nSlot);
	IDREADERDLL_API int WINAPI ISO7816_CardRemove(int nSlot);
	IDREADERDLL_API int WINAPI ISO7816_TransApdu(int nReaderSlot, unsigned char *pSendDatas, int nSendLen, unsigned char *pRecvDatas, int *nRecvLen);

	//---------------------------------------------------------------------------
	//ISO14443相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API int WINAPI ISO14443_TransApdu(int nReaderSlot, unsigned char *pSendDatas, int nSendLen, unsigned char *pRecvDatas, int *nRecvLen);

	//---------------------------------------------------------------------------
	//MIFARE卡相关函数
	//---------------------------------------------------------------------------
	IDREADERDLL_API int WINAPI MIFARE_Authentication(unsigned char bSectorNo, unsigned char *pbKeyA, unsigned char *pbKeyB);
	IDREADERDLL_API int WINAPI MIFARE_ReadData(unsigned char bBlock, unsigned char *data, int nLen);
	IDREADERDLL_API int WINAPI MIFARE_WrtieData(unsigned char bBlock, unsigned char *data, int nLen);
	IDREADERDLL_API int WINAPI MIFARE_IncrementValue(unsigned char bBlock, unsigned int nValue);
	IDREADERDLL_API int WINAPI MIFARE_DecrementValue(unsigned char bBlock, unsigned int nValue);
	IDREADERDLL_API int WINAPI MIFARE_ReadValue(unsigned char bBlock, unsigned int *pnValue);
	IDREADERDLL_API int WINAPI MIFARE_InitValue(unsigned char bBlock, unsigned int nValue);
	IDREADERDLL_API int WINAPI MIFARE_WriteSectorTrailer(unsigned char bBlock, unsigned char *pbKEYA, unsigned char *pbKEYB, unsigned char *pbAccessBits);

	//---------------------------------------------------------------------------
	//机读旅行证件相关函数
	//---------------------------------------------------------------------------
		typedef struct stEPP_Info {
		int  DocumentType;           //证件类型:1-电子护照，2-港澳通行证，3-台湾通行证，4-港澳居民往来内地通行证，5-台湾居民往来内地通行证，6-旧版港澳居民来往内地通行证，7-旧版台湾居民来往内地通行证，9-其他电子证件
		char DocumentNumber[10];     //证件号码	
		char Name[62];				 //英文姓名
		char Gender[2];				 //性别
		char DateOfBorn[10];     	 //生日YYMMDD
		char DateOfExpiry[10]; 		 //证件有效期至YYMMDD
		char DateOfIssue[10];         //签发日期YYMMDD
		char IssuingCountryIso[4];   //签发国代码XXX
		char IssuingCountryName[62]; //签发国名称
		char NationalityIso[4];      //国籍或民族代码
		char NationalityName[62];    //国籍或民族名称
		char IssueTimes[4];          //换证次数XX
		char CustNo[12];             //港澳回乡证上的港澳证件号码//新版港澳回乡证上的港澳证件号码或新版台胞证上的身份证号码
		char CustName[32];           //中文姓名	
		char AddressOfBorn[76];      //出生地点
		char Address[76];            //住址	
		char MRZ[98];                //芯片MRZ码
		char MRZ1[46];   			 //芯片MRZ码-第一行
		char MRZ2[46];   			 //芯片MRZ码-第二行
		char MRZ3[46];               //芯片MRZ码-第三行
		char PhotoName[1024];        //照片保存路径
	}EPP_Info;
	IDREADERDLL_API int WINAPI EPP_GetInfo(EPP_Info *pInfo);
	IDREADERDLL_API int WINAPI EPP_Authentication(const unsigned char *pn, const unsigned char *bod, const unsigned char *eod);
	IDREADERDLL_API int WINAPI EPP_Read_Content(int active);
	IDREADERDLL_API int WINAPI EPP_Read_Content_Path(char* cPath, int active);

	typedef struct stBC_Info
	{
		int DG0201_Len;
		unsigned char DG0201[200];
		int DG0101_Len;
		unsigned char DG0101[200];
		int DG0102_Len;
		unsigned char DG0102[200];

		char ICCardNo[20];
		char IDNo[20];
		char Name[40];
		char ValidThru[10];
		int Track1Len;
		unsigned char Track1[200];
		int Track2Len;
		unsigned char Track2[200];
	}BC_INFO;
	IDREADERDLL_API int WINAPI BC_Read_Content(BC_INFO *pInfo);

	typedef struct stSSC_Info
	{
		int SSSE_EF05_Len;
		unsigned char SSSE_EF05[100];
		int SSSE_EF06_Len;
		unsigned char SSSE_EF06[100];
		int SSSE_EF07_Len;
		unsigned char SSSE_EF07[300];

		char ICCardNo[20];
		char IDNo[20];
		char Name[40];
	}SSC_INFO;
	IDREADERDLL_API int WINAPI  SSC_Authentication(int nReaderSlot);
	IDREADERDLL_API int WINAPI  SSC_Read_Content(int nReaderSlot, SSC_INFO *pInfo);

	IDREADERDLL_API int WINAPI  EID_Authentication(unsigned char *byEidCardID);
	IDREADERDLL_API int WINAPI  EID_Read_Content(unsigned char *byEidCardID);

#ifdef __cplusplus
}
#endif 


