第二代居民身份证阅读器GTICR-100函数包使用手册成都国腾2005.4文档控制文档更新记录地址:成都市高新西区国腾园3号楼3楼邮编:611731目录1概述 (4)2定义 (4)3函数列表 (4)4函数调用流程 (6)5函数说明 (6)6用户信息函数组使用时的调用顺序说明 (12)7一个完整的示例: (13)地址:成都市高新西区国腾园3号楼3楼邮编:6117311概述本手册是操作身份证阅读器应用函数的定义格式、调用方法和返回值的说明。
1.使用USB接口则请先安装对应系统的USB驱动;2.termb.dll是主DLL, WltRS.dll被termb.dll调用;用户可不必关心WltRS.dll,但2个DLL要求要放在同一个目录下;3.termb.dll和WltRS.dll同时拷贝到调用此Dll的应用软件Exe文件所在目录下。
4.termb.dll 输出的文件放在调用者(*.exe)所在目录;2定义应用函数开发包含在下列文件:termb.dll API函数的动态联接库(termb.dll的输出文件放在调用者所在目录中)适用操作系统:Windows NT: 需要NT 3.1版或以后版本Windows: 需要 Windows 98、Windows 2000或以后版本适用开发语言:Visual C++ 5.0 及以后版本Visual Basic 5.0 及以后版本DELPHI 3.0 及以后版本PowerBuilder 6.0 及以后版本3函数列表地址:成都市高新西区国腾园3号楼3楼邮编:611731地址:成都市高新西区国腾园3号楼3楼邮编:6117314函数调用流程5函数说明5.1 初始化串口原型:int InitComm (int Port)说明:本函数用于计算机的设备初始化。
参数:Port:返回值:地址:成都市高新西区国腾园3号楼3楼邮编:611731示例:#include <termb.h>int main(){int li_ret=0;int li_Port=1;li_ret=InitComm(li_Port);return li_ret;}5.2 关闭串口原型:int CloseComm(void)说明:本函数用于关闭计算机已经打开的串口。
参数:无返回值:示例:#include <termb.h>int main(){int li_ret=0;li_ret= CloseComm()return li_ret;}5.3 卡认证原型:int Authenticate (void)说明:本函数用于读卡器和卡片之间的合法身份确认。
参数:无返回值:地址:成都市高新西区国腾园3号楼3楼邮编:611731注意:若卡片放置后发生认证错误时,应移走卡片重新放置。
示例:#include <termb.h>int main(){int li_ret=0;li_ret= authenticate ()return li_ret;}注意:若采用查询方式自动判断卡片是否放置,则间隔时间建议大于300ms。
5.4读卡操作原型:int Read_Content(int Active);说明:本函数用于通过读卡器从非接触卡中读取相应信息。
参数:Active 读取信息类型返回值:注意:1、读完基本信息后,若需要立即读取最新住址信息或芯片管理号,在未移走卡片的情况下可以不用卡认证;2、单独读取最新住址信息或芯片管理号时,需要先进行卡认证;3、若卡片放置后发生读卡错误时,应移走卡片重新放置。
地址:成都市高新西区国腾园3号楼3楼邮编:611731地址:成都市高新西区国腾园3号楼3楼邮编:6117315.5 用户信息函数组该组函数用于读取当前系统缓冲中的二代证卡内信息。
该组函数具有如下特点:●得到的字符信息全部为ANSI编码方式;可以直接用来显示;●得到的字符信息已经按照相关标准作了相应转换;将性别编码转换成了相应的文字信息(如1-“男”),将民族编码转换成了相应的文字信息(如04-“藏”);●该组函数返回值表示一致,含义如下:0:表示取到的字符信息不完整,增大strTmp参数分配的内存,就可完整读出信息;(用户信息各字段的长度定义见下表)非0:表示读出的字节总数;用户信息各字段的长度定义(单位:字节)地址:成都市高新西区国腾园3号楼3楼邮编:611731A.读取卡内姓名信息原型:int STDCALL GetPeopleName(char *strTmp, unsigned int strLen);说明:本函数用于读取ANSI字符编码方式的姓名信息;参数:[out] strTmp 读到的信息;[in] strLen 表示strTmp 参数分配的内存空间大小(单位:字节);B.其他函数原型如下:读性别信息:int _stdcall GetPeopleSex(char *strTmp, unsigned int strLen);读民族信息:int _stdcall GetPeopleNation(char *strTmp, unsigned int strLen);读出生日期:int _stdcall GetPeopleBirthday(char *strTmp, unsigned int strLen);读住址信息:int _stdcall GetPeopleAddress(char *strTmp, unsigned int strLen);读身份号码:int _stdcall GetPeopleIDCode(char *strTmp, unsigned int strLen);读签发机关:int _stdcall GetDepartment(char *strTmp, unsigned int strLen);读有效启始日期:int _stdcall GetStartDate(char *strTmp, unsigned int strLen);读有效截止日期:int _stdcall GetEndDate(char *strTmp, unsigned int strLen);读保留信息:int _stdcall GetReserve(char *strTmp, unsigned int strLen);读照片信息:int _stdcall GetPhotoBMP(char *Photo, unsigned int Len);5.6 数据解析函数以下两个函数主要是用在无卡状态下解析保存在文件中的历史二代证信息;●将人员基本信息文件名(带全路径)通过SetBaseData函数送入termb.dll中后,该Dll 将解析人员基本信息;外部程序可通过调用“读用户信息函数组”中的函数得到想要的信息;●将人员WLT类型的照片文件名(带全路径)通过SetPhoteData函数送入termb.dll后,在二代证机具联机状态下(不需要卡),该dll将WLT文件解压成BMP文件,地址:成都市高新西区国腾园3号楼3楼邮编:611731外部程序可通过调用“读用户信息函数组”中的GetPhotoBMP函数得到BMP文件的内容信息;●参数说明:[in] Fname 文件的全路径名;●返回值说明:1——表示正确执行了功能;0——表示文件已损坏,或非标准格式,或文件大小过大;A.设置人员基本信息int _stdcall SetBaseData(char *FName);B.设置人员照片信息;int _stdcall SetPhoteData(char *FName);6用户信息函数组使用时的调用顺序说明6.1 联机工作状态下:6.2 无卡时对保存在文件中的信息进行解析时:备注:上述两种应用场景可灵活的动态切换。
7一个完整的示例:DELPHI调用示例:unit Unit1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, Buttons, ExtCtrls;typeTForm1 = class(TForm)BitBtn1: TBitBtn;Button2: TButton;Button3: TButton;Image1: TImage;procedure FormClose(Sender: TObject; var Action: TCloseAction);procedure BitBtn1Click(Sender: TObject);procedure FormCreate(Sender: TObject);procedure Button3Click(Sender: TObject);procedure Button2Click(Sender: TObject);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;地址:成都市高新西区国腾园3号楼3楼邮编:611731mInitComm:Function(Port:integer):integer;Stdcall;mCloseComm:Function:integer;stdcall;mAuthenticate:Function:integer;stdcall;mRead_Content:Function(Active:integer):integer;stdcall;GetName:Function(info:pchar;len:integer):integer;stdcall;GetSex:Function(info:pchar;len:integer):integer;stdcall;GetNation:Function(info:pchar;len:integer):integer;stdcall;GetAddress:Function(info:pchar;len:integer):integer;stdcall;GetBirthday:Function(info:pchar;len:integer):integer;stdcall;GetCode:Function(info:pchar;len:integer):integer;stdcall;GetDepartment:Function(info:pchar;len:integer):integer;stdcall;GetStartDate:Function(info:pchar;len:integer):integer;stdcall;GetEndDate:Function(info:pchar;len:integer):integer;stdcall;GetReserve:Function(info:pchar;len:integer):integer;stdcall;GetPhotoBMP:Function(info:pchar;len:integer):integer;stdcall;SetBaseData:Function(filename:string):integer;stdcall;SetPhotoData:Function(filename:string):integer;stdcall;DLLHandle:Integer;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);var i:integer;DLLPath:String;beginDLLPath:=ExtractFiledir(Application.exeName);DLLPath:=DLLPath+'\termb.dll';DLLHandle:=LoadLibrary(Pchar(DLLPath));@mInitComm:=GetProcAddress(DLLHandle,'InitComm');@mCloseComm:=GetProcAddress(DLLHandle,'CloseComm');@mAuthenticate:=GetProcAddress(DLLHandle,'Authenticate');@mRead_Content:=GetProcAddress(DLLHandle,'Read_Content');@GetName:=GetProcAddress(DLLHandle,'GetPeopleName');@GetSex:=GetProcAddress(DLLHandle,'GetPeopleSex');@GetNation:=GetProcAddress(DLLHandle,'GetPeopleNation');@GetAddress:=GetProcAddress(DLLHandle,'GetPeopleAddress');@GetBirthday:=GetProcAddress(DLLHandle,'GetPeopleBirthday');@GetCode:=GetProcAddress(DLLHandle,'GetPeopleIDCode');地址:成都市高新西区国腾园3号楼3楼邮编:611731@GetDepartment:=GetProcAddress(DLLHandle,'GetDepartment');@GetStartDate:=GetProcAddress(DLLHandle,'GetStartDate');@GetEndDate:=GetProcAddress(DLLHandle,'GetEndDate');@GetReserve:=GetProcAddress(DLLHandle,'GetReserve');@GetPhotoBMP:=GetProcAddress(DLLHandle,'GetPhotoBMP');@SetBaseData:=GetProcAddress(DLLHandle,'SetBaseData');@SetPhotoData:=GetProcAddress(DLLHandle,'SetPhotoData');end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);beginif DLLHandle<>null thenfreeLibrary(DLLHandle);end;procedure TForm1.BitBtn1Click(Sender: TObject);beginmInitComm(1);sleep(1000);mAuthenticate;sleep(2000);mRead_Content(1);sleep(2000);Button3Click(self);Application.ProcessMessages;mRead_Content(2);sleep(2000);mRead_Content(3);sleep(1000);mRead_Content(5);sleep(1000);mCloseComm;end;procedure TForm1.Button3Click(Sender: TObject);var info:array[1..100] of char;photo:array[1..102400] of char;fileHandle:THandle;Len:integer;beginfillchar(info,100,#0);GetName(@info[1],100);地址:成都市高新西区国腾园3号楼3楼邮编:611731showmessage(info);fillchar(info,100,#0);GetSex(@info[1],100);showmessage(info);fillchar(info,100,#0);GetNation(@info[1],100);showmessage(info);fillchar(info,100,#0);GetAddress(@info[1],100);showmessage(info);fillchar(info,100,#0);GetBirthday(@info[1],100);showmessage(info);fillchar(info,100,#0);GetCode(@info[1],100);showmessage(info);fillchar(info,100,#0);GetDepartment(@info[1],100);showmessage(info);fillchar(info,100,#0);GetStartDate(@info[1],100);showmessage(info);fillchar(info,100,#0);GetEndDate(@info[1],100);showmessage(info);fillchar(info,100,#0);GetReserve(@info[1],100);showmessage(info);fillchar(photo,100,#0);Len:=GetPhotoBMP(@photo[1],100*1024);fileHandle:=FileCreate('F:\VC++Project\IDCardReader\Debug\photo.bmp');if fileHandle<>0 then地址:成都市高新西区国腾园3号楼3楼邮编:611731beginFileWrite(fileHandle,photo,Len);FileClose(fileHandle);image1.Picture.LoadFromFile('F:\VC++Project\IDCardReader\Debug\photo.bmp');end;end;procedure TForm1.Button2Click(Sender: TObject);var txtFile:string;Wltfile:String;begintxtFile:='F:\VC++Project\IDCardReader\Debug\WZ.txt';wltFile:='F:\VC++Project\IDCardReader\Debug\XP.wlt';SetBaseData(txtFile);SetPhotoData(wltFile);Button3Click(self);end;end.地址:成都市高新西区国腾园3号楼3楼邮编:611731。