16,748
社区成员
发帖
与我相关
我的任务
分享
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
OpenCom = function (Comport:integer;Baud:integer):integer;stdcall;
SelModule = function (PortType:integer;Module:integer):integer;stdcall;
CloseCom = function ():integer;stdcall;
ReadCard = function (Name,Sex,Nation,Birthday,Address,ID,Department,
StartDate,EndDate,Reserve,AppAddress1,PhotoData:PAnsiChar):integer;stdcall;
TIDCardInfo=record
_Name:array[1..31] of AnsiChar;
_Sex:array[1..3] of AnsiChar;
_Nation:array[1..51] of AnsiChar;
_Birthday:array[1..9] of AnsiChar;
_Address:array[1..51] of AnsiChar;
_ID:array[1..19] of AnsiChar;
_Department:array[1..51] of AnsiChar;
_StartDate:array[1..9] of AnsiChar;
_EndDate:array[1..9] of AnsiChar;
_Reserve:array[1..51] of AnsiChar;
_AppAddress1:array[1..51] of AnsiChar;
_PhotoData:array[1..51] of AnsiChar;
Freadinfo:Integer; //读卡状态
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var DllHandle:THandle;
ComPort,Baud,HBaud,result:integer;
PortType,Module:integer;
oc:OpenCom;
sm:SelModule;
cc:CloseCom;
rc:ReadCard;
idci:TIDCardInfo;
begin
ComPort:=1;Baud:=9600;HBaud:=115200;result:=22;
PortType:=0;Module:=3;
DLLHandle:=LoadLibrary('JCJP_API.dll');
if DLLHandle<>0 then
begin
@oc:=GetProcAddress(DllHandle,'Open_Com');
if @oc<>nil then
begin
if( oc(ComPort,Baud) = 0 )then
begin
@sm:= GetProcAddress(DllHandle,'Sel_Module');
if @sm<>nil then
begin
if(sm(PortType,Module) = 0)then
begin
@cc:= GetProcAddress(DllHandle,'Close_Com');
if( cc()=0)then
begin
@oc:=GetProcAddress(DllHandle,'Open_Com');
if(@oc<>nil)then
begin
if(oc(ComPort,HBaud)=0)then
begin
@rc:= GetProcAddress(DllHandle,'ReadCard');
if @rc<>nil then
begin
idci.Freadinfo:=rc(@idci._Name,@idci._Sex,@idci._Nation,
@idci._Birthday,@idci._Address,@idci._ID,@idci._Department,
@idci._StartDate,@idci._EndDate,@idci._Reserve,@idci._AppAddress1,
@idci._PhotoData);
showmessage('没有找到二代身份证,读取失败!');
result:=sm(PortType,0);
result:=cc();
end
else
showmessage('rc is nil');
end
else
showmessage('高频打开串口失败');
end
else
showmessage('oc is nil');
end
else
showmessage('关闭串口失败');
end
else
begin
showmessage('选择模式失败');
end;
end
else
begin
showmessage('sm is nil');
end;
end
else
showmessage('串口打开失败!');
end
else
showmessage('oc is nil');
end
else
showmessage('222');
FreeLibrary(DLLHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
end.
var
sfzName,sfzSex,sfzNation,sfzBirthday,sfzAddress,sfzID,sfzDepartment,
sfzStartDate,sfzEndDate,sfzReserve,sfzAppAddress1,sfzPhotoData:pchar;
这个地方:
ReadCard = function (var Name:pChar;var Sex:pChar;var Nation:pChar;var Birthday:pChar;
var Address:pChar;var ID:pChar;var Department:pChar;var StartDate:pChar;var EndDate:pChar;
var Reserve:pChar;var AppAddress1:pChar;var PhotoData:pChar):integer;stdcall;
function ReadBaseInfosPhoto(Name,Sex,Folk,BirthDay,ID,Address,Issue,dBegin,dEnd,Photopath:PAnsiChar):integer;stdcall;External '.\dll\sdtapi.dll';
type
TIDCardInfo=record
_Name:array[1..31] of AnsiChar;
_Sex:array[1..3] of AnsiChar;
_Folk:array[1..10] of AnsiChar;
_Birthday:array[1..9] of AnsiChar;
_Addr:array[1..71] of AnsiChar;
_ID:array[1..19] of AnsiChar;
_Issue:array[1..31] of AnsiChar;
_dBegin:array[1..9] of AnsiChar;
_dEnd:array[1..9] of AnsiChar;
private
Fport:Integer; //端口状态
Fauthenticate:Integer; //认证状态
Freadinfo:Integer; //读卡状态
end;
ReadCard.Freadinfo:=ReadBaseInfosPhoto(@ReadCard._Name,@ReadCard._Sex,@ReadCard._Folk,@ReadCard._Birthday,@ReadCard._ID,@ReadCard._Addr,@ReadCard._Issue,@ReadCard._dBegin,@ReadCard._dEnd,PAnsiChar(AnsiString(Fphotopath)));