新中新身份证阅读器C++实现

2024-08-31 12:52

本文主要是介绍新中新身份证阅读器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++实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1123964

相关文章

Go语言开发实现查询IP信息的MCP服务器

《Go语言开发实现查询IP信息的MCP服务器》随着MCP的快速普及和广泛应用,MCP服务器也层出不穷,本文将详细介绍如何在Go语言中使用go-mcp库来开发一个查询IP信息的MCP... 目录前言mcp-ip-geo 服务器目录结构说明查询 IP 信息功能实现工具实现工具管理查询单个 IP 信息工具的实现服

SpringBoot基于配置实现短信服务策略的动态切换

《SpringBoot基于配置实现短信服务策略的动态切换》这篇文章主要为大家详细介绍了SpringBoot在接入多个短信服务商(如阿里云、腾讯云、华为云)后,如何根据配置或环境切换使用不同的服务商,需... 目录目标功能示例配置(application.yml)配置类绑定短信发送策略接口示例:阿里云 & 腾

python实现svg图片转换为png和gif

《python实现svg图片转换为png和gif》这篇文章主要为大家详细介绍了python如何实现将svg图片格式转换为png和gif,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录python实现svg图片转换为png和gifpython实现图片格式之间的相互转换延展:基于Py

Python利用ElementTree实现快速解析XML文件

《Python利用ElementTree实现快速解析XML文件》ElementTree是Python标准库的一部分,而且是Python标准库中用于解析和操作XML数据的模块,下面小编就来和大家详细讲讲... 目录一、XML文件解析到底有多重要二、ElementTree快速入门1. 加载XML的两种方式2.

Java的栈与队列实现代码解析

《Java的栈与队列实现代码解析》栈是常见的线性数据结构,栈的特点是以先进后出的形式,后进先出,先进后出,分为栈底和栈顶,栈应用于内存的分配,表达式求值,存储临时的数据和方法的调用等,本文给大家介绍J... 目录栈的概念(Stack)栈的实现代码队列(Queue)模拟实现队列(双链表实现)循环队列(循环数组

C++如何通过Qt反射机制实现数据类序列化

《C++如何通过Qt反射机制实现数据类序列化》在C++工程中经常需要使用数据类,并对数据类进行存储、打印、调试等操作,所以本文就来聊聊C++如何通过Qt反射机制实现数据类序列化吧... 目录设计预期设计思路代码实现使用方法在 C++ 工程中经常需要使用数据类,并对数据类进行存储、打印、调试等操作。由于数据类

Python实现图片分割的多种方法总结

《Python实现图片分割的多种方法总结》图片分割是图像处理中的一个重要任务,它的目标是将图像划分为多个区域或者对象,本文为大家整理了一些常用的分割方法,大家可以根据需求自行选择... 目录1. 基于传统图像处理的分割方法(1) 使用固定阈值分割图片(2) 自适应阈值分割(3) 使用图像边缘检测分割(4)

Android实现在线预览office文档的示例详解

《Android实现在线预览office文档的示例详解》在移动端展示在线Office文档(如Word、Excel、PPT)是一项常见需求,这篇文章为大家重点介绍了两种方案的实现方法,希望对大家有一定的... 目录一、项目概述二、相关技术知识三、实现思路3.1 方案一:WebView + Office Onl

C# foreach 循环中获取索引的实现方式

《C#foreach循环中获取索引的实现方式》:本文主要介绍C#foreach循环中获取索引的实现方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、手动维护索引变量二、LINQ Select + 元组解构三、扩展方法封装索引四、使用 for 循环替代

Spring Security+JWT如何实现前后端分离权限控制

《SpringSecurity+JWT如何实现前后端分离权限控制》本篇将手把手教你用SpringSecurity+JWT搭建一套完整的登录认证与权限控制体系,具有很好的参考价值,希望对大家... 目录Spring Security+JWT实现前后端分离权限控制实战一、为什么要用 JWT?二、JWT 基本结构