本文主要是介绍新中新身份证阅读器C++实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
最近有个身份证识别功能需要实现,通过整理把接口进行了封装整理,方便其他业务逻辑调用,代码如下:
1、IDCardHelper.h
#pragma once
#include <map>#pragma pack(1)
typedef struct tagIDCardData {char Name[32]; //姓名 char Sex[6]; //性别char Nation[64]; //名族char Born[18]; //出生日期char Address[72]; //住址char IDCardNo[38]; //身份证号char GrantDept[32]; //发证机关char UserLifeBegin[18]; // 有效开始日期char UserLifeEnd[18]; // 有效截止日期char PassID[20]; // 通行证号码char IssuesTimes[6]; //签发次数char reserved[12]; // 保留char PhotoFileName[255];// 照片路径char CardType[4]; //证件类型char EngName[122]; //英文名char CertVol[6]; //证件版本号
}IDCardData;
#pragma pack()typedef int(*ProgressCallback)(int progress);//二代证相关API---------------------------------------------------------------------------------------
typedef int (_stdcall *Syn_GetCOMBaud)(int iPort, unsigned int * puiBaudRate);
typedef int (_stdcall *Syn_SetCOMBaud)(int iPort, unsigned int uiCurrBaud, unsigned int uiSetBaud);
typedef int (_stdcall *Syn_OpenPort)(int iPort);
typedef int (_stdcall *Syn_ClosePort)(int iPort);
//
// SAM类函数
//
//
typedef int (_stdcall *Syn_SetMaxRFByte)(int iPort, unsigned char ucByte, int bIfOpen);
typedef int (_stdcall *Syn_ResetSAM)(int iPort, int iIfOpen);
typedef int (_stdcall *Syn_GetSAMStatus)(int iPort, int iIfOpen);
typedef int (_stdcall *Syn_GetSAMID)(int iPort, unsigned char * pucSAMID, int iIfOpen);
typedef int (_stdcall *Syn_GetSAMIDToStr)(int iPort, char * pcSAMID, int iIfOpen);
//
// 身份证卡类函数
//
//
typedef int (_stdcall *Syn_StartFindIDCard)(int iPort, unsigned char * pucIIN, int iIfOpen);
typedef int (_stdcall *Syn_SelectIDCard)(int iPort, unsigned char * pucSN, int iIfOpen);
typedef int (_stdcall *Syn_ReadBaseMsg)(int iPort,unsigned char * pucCHMsg,unsigned int * puiCHMsgLen,unsigned char * pucPHMsg,unsigned int * puiPHMsgLen,int iIfOpen);
typedef int (_stdcall *Syn_ReadBaseMsgToFile)(int iPort,char * pcCHMsgFileName,unsigned int * puiCHMsgFileLen,char * pcPHMsgFileName,unsigned int * puiPHMsgFileLen,int iIfOpen);
typedef int (_stdcall *Syn_ReadBaseFPMsg)(int iPort,unsigned char * pucCHMsg,unsigned int * puiCHMsgLen,unsigned char * pucPHMsg,unsigned int * puiPHMsgLen,unsigned char * pucFPMsg,unsigned int * puiFPMsgLen,int iIfOpen);
typedef int (_stdcall *Syn_ReadBaseFPMsgToFile)(int iPort,char * pcCHMsgFileName,unsigned int * puiCHMsgFileLen,char * pcPHMsgFileName,unsigned int * puiPHMsgFileLen,char * pcFPMsgFileName,unsigned int * puiFPMsgFileLen,int iIfOpen);
typedef int (_stdcall *Syn_ReadNewAppMsg)(int iPort, unsigned char * pucAppMsg, unsigned int * puiAppMsgLen, int iIfOpen);
typedef int (_stdcall *Syn_GetBmp)(int iPort, char * Wlt_File);typedef int (_stdcall *Syn_ReadMsg)(int iPort, int iIfOpen, IDCardData *pIDCardData);
typedef int (_stdcall *Syn_ReadFPMsg)(int iPort, int iIfOpen, IDCardData *pIDCardData, char * cFPhotoname);typedef int (_stdcall *Syn_FindReader)();
typedef int (_stdcall *Syn_FindUSBReader)();typedef int (_stdcall *Syn_BmpToJpeg)(char * cBmpName, char * cJpegName);
typedef int (_stdcall *Syn_PhotoToStrBase64)(char * cBase64, int * iLen, char *cPhotoName);
typedef int (_stdcall *Syn_StrBase64ToPhoto)(char * cBase64, int iLen, char *cPhotoName);
//
// 设置附加功能函数
//
//
typedef int (_stdcall *Syn_SetPhotoPath)(int iOption, char * cPhotoPath);
typedef int (_stdcall *Syn_SetPhotoType)(int iType);
typedef int (_stdcall *Syn_SetPhotoName)(int iType);
typedef int (_stdcall *Syn_SetPhotoNameEx)(int iType, char * cPhotoname);
typedef int (_stdcall *Syn_SetSexType)(int iType);
typedef int (_stdcall *Syn_SetNationType)(int iType);
typedef int (_stdcall *Syn_SetBornType)(int iType);
typedef int (_stdcall *Syn_SetUserLifeBType)(int iType);
typedef int (_stdcall *Syn_SetUserLifeEType)(int iType, int iOption);//
// USBHID函数
//
//typedef int (_stdcall *Syn_USBHIDM1Reset)(int iPort, DWORD * pdwCardSN, unsigned char * pbSize);
typedef int (_stdcall *Syn_USBHIDM1AuthenKey)(int iPort, unsigned char KeyType, unsigned char BlockNo, unsigned char * pKey);
typedef int (_stdcall *Syn_USBHIDM1ReadBlock)(int iPort, unsigned char BlockNo, unsigned char * pBlock);
typedef int (_stdcall *Syn_USBHIDM1WriteBlock)(int iPort, unsigned char BlockNo, unsigned char * pBlock);
typedef int (_stdcall *Syn_USBHIDM1Halt)(int iPort);
typedef int (_stdcall *Syn_USBHIDReadFactoryInfo)(int iPort,unsigned char * pFactory,unsigned char * pVol,unsigned char * pSerialNo,unsigned char * pReserved);
typedef int (_stdcall *Syn_USBHIDWriteFactoryInfo)(int iPort,unsigned char * pFactory,unsigned char * pVol,unsigned char * pSerialNo,unsigned char * pReserved);
typedef int (_stdcall *Syn_USBHIDReadUserInfo)(int iPort, unsigned char *pInfo);
typedef int (_stdcall *Syn_USBHIDWriteUserInfo)(int iPort, unsigned char *pInfo);
typedef int (_stdcall *Syn_USBHIDGetMaxByte)(int iPort, unsigned char *pSAMMaxByte, unsigned char *pARMVol);
typedef int (_stdcall *Syn_USBHIDSendSound)(int iPort, unsigned char ucSound);
typedef int (_stdcall *Syn_USBHIDControlLED)(int iPort, unsigned char ucLed);
typedef int (_stdcall *Syn_USBHIDControlBeep)(int iPort, unsigned char ucType, unsigned short usTime);
typedef int (_stdcall *Syn_USBHIDGetSecCardID)(int iPort, unsigned char * pdwCardSN);typedef int (_stdcall *Syn_USBHIDSIMpowerOn)(int iPort, unsigned char * ucATR, unsigned char * ucLen);
typedef int (_stdcall *Syn_USBHIDSIMpowerOff)(int iPort);
typedef int (_stdcall *Syn_USBHIDSIMAPDU)(int iPort, int slen, unsigned char *datasend, int* rlen, unsigned char* datareceive);
//typedef int (_stdcall *Syn_USBHIDReadUserMac)(int iPort, unsigned char *pMac);
typedef int (_stdcall *Syn_USBHIDWriteUserMac)(int iPort, unsigned char *pMac);
//add new interface
//int _stdcall Syn_USBHIDSetTransportType(int iPort,int type);
typedef int (_stdcall *Syn_USBHIDSetUserIDCode)(int iPort, unsigned char *code, int len);
typedef int (_stdcall *Syn_USBHIDIsEncryptMode)(int iPort);
typedef int (_stdcall *Syn_USBHIDdoUpdate)(int iPort, unsigned char *updateBuffer, long bufferLen, ProgressCallback progressCallback);
//
// USBReade.dll USBHID函数
//
//
//typedef int (_stdcall *Syn_USBOpenPort)(int iPort);
//typedef int (_stdcall *Syn_USBClosePort)(int iPort);
//typedef int (_stdcall *Syn_USBSetMaxRFByte)(int iPort, unsigned char ucByte, int bIfOpen);
//typedef int (_stdcall *Syn_USBStartFindIDCard)(int iPort, unsigned char * pucIIN, int iIfOpen);
//typedef int (_stdcall *Syn_USBSelectIDCard)(int iPort, unsigned char * pucSN, int iIfOpen);
//typedef int (_stdcall *Syn_USBReadBaseMsg)(
// int iPort,
// unsigned char * pucCHMsg,
// unsigned int * puiCHMsgLen,
// unsigned char * pucPHMsg,
// unsigned int * puiPHMsgLen,
// int iIfOpen);
//typedef int (_stdcall *Syn_USBReadBaseFPMsg)(
// int iPort,
// unsigned char * pucCHMsg,
// unsigned int * puiCHMsgLen,
// unsigned char * pucPHMsg,
// unsigned int * puiPHMsgLen,
// unsigned char * pucFPMsg,
// unsigned int * puiFPMsgLen,
// int iIfOpen
// );
//typedef int (_stdcall *Syn_USBReadNewAppMsg)(int iPort, unsigned char * pucAppMsg, unsigned int * puiAppMsgLen, int iIfOpen);//typedef int (_stdcall *Syn_USBGetSAMID)(int iPort, unsigned char * pucSAMID, int iIfOpen);
//typedef int (_stdcall *Syn_USBGetSAMIDToStr)(int iPort, char * pcSAMID, int iIfOpen);//typedef int (_stdcall *Syn_USBM1Reset)(int iPort, DWORD * pdwCardSN, unsigned char * pbSize);
//typedef int (_stdcall *Syn_USBM1AuthenKey)(int iPort, unsigned char KeyType, unsigned char BlockNo, unsigned char * pKey);
//typedef int (_stdcall *Syn_USBM1ReadBlock)(int iPort, unsigned char BlockNo, unsigned char * pBlock);
//typedef int (_stdcall *Syn_USBM1WriteBlock)(int iPort, unsigned char BlockNo, unsigned char * pBlock);
//typedef int (_stdcall *Syn_USBM1Halt)(int iPort);
//typedef int (_stdcall *Syn_USBReadFactoryInfo)(
// int iPort,
// unsigned char * pFactory,
// unsigned char * pVol,
// unsigned char * pSerialNo,
// unsigned char * pReserved);
//typedef int (_stdcall *Syn_USBWriteFactoryInfo)(
// int iPort,
// unsigned char * pFactory,
// unsigned char * pVol,
// unsigned char * pSerialNo,
// unsigned char * pReserved);
//typedef int (_stdcall *Syn_USBReadUserInfo)(int iPort, unsigned char *pInfo);
//typedef int (_stdcall *Syn_USBWriteUserInfo)(int iPort, unsigned char *pInfo);
//typedef int (_stdcall *Syn_USBGetMaxByte)(int iPort, unsigned char *pSAMMaxByte, unsigned char *pARMVol);
//typedef int (_stdcall *Syn_USBSendSound)(int iPort, unsigned char ucSound);
//typedef int (_stdcall *Syn_USBControlLED)(int iPort, unsigned char ucLed);
//typedef int (_stdcall *Syn_USBControlBeep)(int iPort, unsigned char ucType, unsigned short usTime);//typedef int (_stdcall *Syn_USBGetSecCardID)(int iPort, unsigned char * pdwCardSN);//typedef int (_stdcall *Syn_USBSIMpowerOn)(int iPort, unsigned char * ucATR, unsigned char * ucLen);
//typedef int (_stdcall *Syn_USBSIMpowerOff)(int iPort);
//typedef int (_stdcall *Syn_USBSIMAPDU)(int iPort, int slen, unsigned char *datasend, int* rlen, unsigned char* datareceive);
//typedef int (_stdcall *Syn_USBReadUserMac)(int iPort, unsigned char *pMac);
//typedef int (_stdcall *Syn_USBWriteUserMac)(int iPort, unsigned char *pMac);
//typedef int (_stdcall *Syn_USBPSAMpowerOn)( int iPort, int slot, unsigned char * ucATR, unsigned char * ucLen);
//typedef int (_stdcall *Syn_USBPSAMpowerOff)( int iPort, int slot);
//typedef int (_stdcall *Syn_USBPSAMAPDU)(int iPort, int slot,int slen,unsigned char *datasend,int* rlen,unsigned char* datareceive);
//typedef int (_stdcall *Syn_USBControlFingerLed)( int iPort,unsigned char ucType,unsigned short usTime);
typedef int (_stdcall *Syn_PSAMpowerOn)( int iPort, int slot, unsigned char * ucATR, unsigned char * ucLen);
typedef int (_stdcall *Syn_PSAMpowerOff)( int iPort, int slot);
typedef int (_stdcall *Syn_PSAMAPDU)(int iPort, int slot,int slen,unsigned char *datasend,int* rlen,unsigned char* datareceive);
typedef int (_stdcall *Syn_ControlFingerLed)( int iPort,unsigned char ucType,unsigned short usTime);
//add new interface
//int _stdcall Syn_USBSetTransportType(int iPort,int type);
//typedef int (_stdcall *Syn_USBSetUserIDCode)(int iPort, unsigned char *code, int len);
//typedef int (_stdcall *Syn_USBIsEncryptMode)(int iPort);
//
这篇关于新中新身份证阅读器C++实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!