[资料]国腾身份证浏览器gticr100-01 termb.dll应用开辟应用手册
第二代居民身份证阅读器GTICR-100
函数包使用手册
成都国腾
2005.4
文档控制
文档更新记录
文 档 编 号: 编制单位 产品部
本次修改日期:2005.04.19 审核单位 总工办
历史修改累记:2 审核主管 技术总监
目 录
1 概述 .............................................................................................................................4 2 定义 .............................................................................................................................4 3 函数列表 ....................................................................................................................4 4 函数调用流程............................................................................................................6 5 函数说明 ....................................................................................................................6 6 用户信息函数组使用时的调用顺序说明 ........................................................11 7 一个完整的示例:................................................................................................ 12
1 概述
本手册是操作身份证阅读器应用函数的定义格式、调用方法和返回值的说明。
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 函数列表
序号 函数定义 函数功能 1. Int _stdcall InitComm(int Port) 初始化串口; 2. int _stdcall CloseComm() 关闭串口; 3. int _stdcall Authenticate() 卡认证; 4. int _stdcall Read_Content(int Active) 读卡操作。 5. int _stdcall GetPeopleName(char *strTmp, int strLen) 得到姓名信息 6. int _stdcall GetPeopleSex(char *strTmp, int strLen) 得到性别信息 7. int _stdcall GetPeopleNation(char *strTmp, int strLen) 得到民族信息 8. int _stdcall GetPeopleBirthday(char *strTmp, int strLen) 得到出生日期 9. int _stdcall GetPeopleAddress(char *strTmp, int strLen) 得到地址信息 10. int _stdcall GetPeopleIDCode(char *strTmp, int strLen) 得到卡号信息 11. int _stdcall GetDepartment(char *strTmp, int strLen) 得到发证机关信息 12. int _stdcall GetStartDate(char *strTmp, int strLen) 得到有效启始日期 13. int _stdcall GetEndDate(char *strTmp, int strLen) 得到有效截止日期
14. int _stdcall GetReserve(char *strTmp, int strLen) 得到保留信息
15. int _stdcall SetBaseData(char *TxtFileName) 设置基本信息
16. int _stdcall SetPhotoData(char *WltFileName) 设置照片WLT信息
4 函数调用流程
开始
初始化串口
读卡器认证
读卡信息
关闭串口
结束
5 函数说明
5.1 初始化串口
原 型:int InitComm (int Port) 说 明:本函数用于计算机的设备初始化。
参 数:Port: 设置设备号
值 意义
串口1 1
串口2 2
串口3 3
串口4 4
。。。
串口16 16
1001 USB1
1002 USB2
1003 USB3
1004 USB4
。。。
1016 USB16 返 回 值:
值 意义
正确 1
其它 错误
示 例:
#include
int main()
{
int li_ret=0;
int li_Port=1;
li_ret=InitComm(li_Port);
return li_ret;
}
5.2 关闭串口
原 型:
int CloseComm(void)
说 明:本函数用于关闭计算机已经打开的串口。
参 数:无
返 回 值:
值 意义
正确 1
其它 错误
示 例:
#include
int main()
{
int li_ret=0;
li_ret= CloseComm()
return li_ret;
}
5.3 卡认证
原 型:int Authenticate (void)
说 明:本函数用于读卡器和卡片之间的合法身份确认。
参 数:无
返 回 值:
值 意义 说明
正确 卡片正确放置时 1
其它 错误 未放卡或卡片放置不正确时
注意:若卡片放置后发生认证错误时,应移走卡片重新放置。
示 例:
#include
int main()
{
int li_ret=0;
li_ret= authenticate ()
return li_ret;
}
注意:若采用查询方式自动判断卡片是否放置,则间隔时间建议大于300ms。
5.4读卡操作
原 型:int Read_Content(int Active);
说 明:本函数用于通过读卡器从非接触卡中读取相应信息。
参 数:Active 读取信息类型 Active值 意义 说明
读基本信息 形成文字信息文件WZ.TXT、相片文件XP.WLT和ZP.BMP 1
只读文字信息 形成文字信息文件WZ.TXT和相片文件XP.WLT 2
读最新住址信息 形成最新住址文件NEWADD.TXT 3
读芯片管理号 形成二进制文件IINSNDN.bin 5
返 回 值:
值 意义
正确 1
读卡错误 0
相片解码错误 -1
wlt文件后缀错误 -2
wlt文件打开错误 -3
wlt文件格式错误 -4
软件未授权 -5
设备连接失败 -6
注意:
1、 读完基本信息后,若需要立即读取最新住址信息或芯片管理号,在未移走卡
片的情况下可以不用卡认证; 2、 单独读取最新住址信息或芯片管理号时,需要先进行卡认证;
3、若卡片放置后发生读卡错误时,应移走卡片重新放置。
文字信息采用GB 13000的UCS-2进行存储,各项目分配如下:
项目 长度(字节) 说明
姓名 汉字 30
性别 代码 2
民族 代码 4
出生 年月日:YYYYMMDD 16
住址 汉字和数字 70
公民身份号码 数字 36
签发机关 汉字 30
有效期起始日期 年月日:YYYYMMDD 16
有效期截止日期 年月日:YYYYMMDD 16
有效期为长期时存储“长期”
预留区 保留信息 36
最新住址 汉字和数字 70
芯片管理号分配如下:
项目 长度(字节) 说明
IIN 4
SN 8
DN 16
5.5 用户信息函数组
该组函数用于读取当前系统缓冲中的二代证卡内信息。该组函数具有如下特点:
, 得到的字符信息全部为ANSI编码方式;可以直接用来显示; , 得到的字符信息已经按照相关标准作了相应转换;将性别编码转换成了相应的文字
信息(如1-“男”),将民族编码转换成了相应的文字信息(如04-“藏”);
, 该组函数返回值表示一致,含义如下:
0:表示取到的字符信息不完整,增大strTmp参数分配的内存,就可完整读出信息;
(用户信息各字段的长度定义见下表)
非0:表示读出的字节总数;
用户信息各字段的长度定义 (单位:字节)
姓名 30
性别 2
民族 4
出生日期 16
住址 70
身份号码 36
签发机关 30
有效启始日期 16
有效截止日期 16
保留 36
A(读取卡内姓名信息
原 型: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文件,
外部程序可通过调用“读用户信息函数组”中的GetPhotoBMP函数得到BMP文件的
内容信息;
, 参数说明:[in] Fname 文件的全路径名;
, 返回值说明:1——表示正确执行了功能;
0——表示文件已损坏,或非标准格式,或文件大小过大;
A. 设置人员基本信息
int _stdcall SetBaseData(char *FName);
B. 设置人员照片信息;
int _stdcall SetPhoteData(char *FName);
6 用户信息函数组使用时的调用顺序说明 6(1 联机工作状态下:
InitComm
Authenticate
仅当参数为1时,用户信
息函数组的输出才得到 Read_content(1) 跟更新;
调用用户信息函
数组中的函数;
6(2 无卡时对保存在文件中的信息进行解析时:
确保机具处于联机 SetBaseData 状态(可无卡)
调用用户信息函数
组中的函数; SetPhotoData
调用用户信息函数
组中的函数;
备注:上述两种应用场景可灵活的动态切换。
7 一个完整的示例:
DELPHI调用示例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
TForm1 = 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;
var
Form1: TForm1;
mInitComm: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;
begin
DLLPath:=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');
@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);
begin
if DLLHandle<>null then
freeLibrary(DLLHandle);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
mInitComm(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;
begin
fillchar(info,100,#0);
GetName(@info[1],100);
showmessage(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
begin
FileWrite(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;
begin
txtFile:='F:\VC++Project\IDCardReader\Debug\WZ.txt';
wltFile:='F:\VC++Project\IDCardReader\Debug\XP.wlt';
SetBaseData(txtFile);
SetPhotoData(wltFile);
Button3Click(self);
end;
end.
本文档为【[资料]国腾身份证浏览器gticr100-01 termb.dll应用开辟应用手册】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。