Delphi 身份证读取。弹出窗体【附上全部代码】

zhangzhen_927116 2013-08-30 10:15:54

unit Main_U;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OBThread, jpeg, StdCtrls, ExtCtrls,IDCardClass_U;

type
TIDCardRead_F = class(TForm)
img_Cover: TImage;
obthrd_ReadID: TOBThread;
lbl_Info: TLabel;
lbl_Con: TLabel;
BtnGlyph_Read: TImage;
BtnGlyph_UnRead: TImage;
ID_Addr: TLabel;
ID_Birth: TLabel;
ID_Depart: TLabel;
ID_ID: TLabel;
ID_Name: TLabel;
ID_Nation: TLabel;
ID_NewAddr: TLabel;
ID_Sex: TLabel;
ID_Time: TLabel;
Image_XP: TImage;
ImageClose: TImage;
ImageMin: TImage;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure ImageCloseClick(Sender: TObject);
procedure obthrd_ReadIDExecute(Sender: TObject; params: Pointer);
procedure BtnGlyph_ReadClick(Sender: TObject);
procedure BtnGlyph_UnReadClick(Sender: TObject);
procedure ImageMinClick(Sender: TObject);
procedure img_CoverMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
UsbOrCom: string;
Port,pucSn,puiCHMsgLen,puiPHMsgLen: integer;
StartReadID,PortEnable: Boolean;
IDCard: TIDCard;
procedure ReadIDCard();//读身份证
{ Private declarations }
public
{ Public declarations }
end;

var
IDCardRead_F: TIDCardRead_F;

implementation
uses IDCardDll_U ;
{$R *.dfm}

procedure TIDCardRead_F.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
IDCard.Destroy;
StartReadID:= False;
if PortEnable then
SDT_ClosePort(Port);
end;

procedure TIDCardRead_F.FormCreate(Sender: TObject);
begin
IDCard:= TIDCard.Create;
PortEnable:= OpenUsbPort(Port);
if PortEnable then
begin
UsbOrCom:= 'U';//连接的类型是通过Usb端口
lbl_Con.Caption:= '连接类型:USB口连接';
lbl_Con.Font.Color:= clGreen;
end
else begin
PortEnable:= OPenComPort(Port);
if PortEnable then
begin
UsbOrCom:= 'C' ; //连接的类型是通过Com端口
lbl_Con.Caption:= '连接类型:串口连接';
lbl_Con.Font.Color:= clGreen;
end
else begin
UsbOrCom:='';
lbl_Con.Caption:= '连接类型:端口错误导致未连接';
lbl_Con.Font.Color:= clRed;
end;
end;
if not PortEnable then
BtnGlyph_Read.Enabled:= False;
StartReadID:= True;
if (StartReadID) and (PortEnable) then
BtnGlyph_ReadClick(nil);
end;

procedure TIDCardRead_F.ImageCloseClick(Sender: TObject);
begin
Close;
end;

procedure TIDCardRead_F.ReadIDCard;
var
iRet : integer;
begin
while (PortEnable) and (StartReadID) do
begin
Sleep(1000);
iRet:= SDT_StartFindIDCard(Port, pucSn, 1); //查卡
if iRet = 159 then
iRet:= SDT_SelectIDCard(Port,pucSn,1) //选卡
else Continue;
if iRet= 144 then
begin
puiCHMsgLen:=0;
puiPHMsgLen:=0;
iRet:= SDT_ReadBaseMsgToFile(1001, 'wz.txt',puiCHMsgLen, 'zp.wlt',puiPHMsgLen,1); //存储文件
end
else Continue;
if iRet =144 then
begin
UsbOrCom:='U';//连接的类型是通过Usb端口
if UsbOrCom ='U' then
iRet := GetBmp('zp.wlt',2)
else if UsbOrCom='C' then //如果连接的类型是Com端口
iRet := GetBmp('zp.wlt',1);
想在这里判断数据库内是否存在这个身份证信息。如果存在打开一个窗体显示信息
if iRet=1 then
begin
Image_XP.Picture.LoadFromFile('zp.bmp');
IDCard.InitInfo(ExtractFilePath(Application.ExeName) +'wz.txt');
ID_Name.Caption:= IDCard.Name;
ID_Sex.Caption:= IDCard.Sex_CName;
ID_Nation.Caption:= IDCard.NATION_CName;
ID_Birth.Caption:= IDCard.BIRTH;
ID_Addr.Caption:= IDCard.ADDRESS;
ID_ID.Caption:= IDCard.IDC;
ID_Depart.Caption:= IDCard.REGORG;
ID_Time.Caption:= IDCard.STARTDATE +'-'+IDCard.ENDDATE;
DeleteFile('zp.bmp');
DeleteFile('wz.txt');
end
else Continue;
end;
end;
end;

procedure TIDCardRead_F.obthrd_ReadIDExecute(Sender: TObject;
params: Pointer);
begin
ReadIDCard ;
end;

procedure TIDCardRead_F.BtnGlyph_ReadClick(Sender: TObject);
begin
StartReadID:= True;
BtnGlyph_Read.Visible:= False;
BtnGlyph_UnRead.Visible:= True;
obthrd_ReadID.Execute(nil);
end;

procedure TIDCardRead_F.BtnGlyph_UnReadClick(Sender: TObject);
begin
BtnGlyph_Read.Visible:= True;
BtnGlyph_UnRead.Visible:= False;
StartReadID:= False;
end;

procedure TIDCardRead_F.ImageMinClick(Sender: TObject);
begin
IDCardRead_F.WindowState:= wsMinimized;
end;

procedure TIDCardRead_F.img_CoverMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if ssleft in shift then
Releasecapture;
perform(WM_SYSCOMMAND,$F012,0);
end;

end.

{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}

unit OBThread;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls;

type
TNotifyEventParams=procedure(Sender : TObject; params : pointer) of object;
TOBThread = class(TComponent)
private
FThreadCount : Integer;
FExclusif : boolean;
FRunOnCreate : boolean;
FOnbegin : TNotifyEvent;
FOnExecute : TNotifyEventParams;
FOnFinish : TNotifyEvent;
FOnFinishAll : TNotifyEvent;
FFreeOnTerminate : boolean;
FAbout: String;
procedure DoCreate;
procedure DoTerminate(Sender : TObject);
protected
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
published
function Execute(p : pointer):Thandle;
function OneThreadIsRunning : boolean;
function GetPriority(Thread:Thandle):TThreadPriority;
procedure SetPriority(Thread:THandle;Priority:TThreadPriority);
procedure QuitThread(Thread:Thandle);
procedure Suspend(Thread:Thandle);
procedure Resume(Thread:Thandle);
property About : String read FAbout write FAbout;
property Exclusif : boolean read FExclusif write FExclusif;
property RunOnCreate : boolean read FRunOnCreate write FRunOnCreate;
property FreeOnTerminate : boolean read FFreeOnTerminate write FFreeOnTerminate;
property Onbegin : TNotifyEvent read FOnbegin write FOnBegin;
property OnExecute : TNotifyEventParams read FOnExecute write FOnExecute;
property OnFinish : TNotifyEvent read FOnFinish write FOnFinish;
property OnFinishAll : TNotifyEvent read FOnFinishAll write FOnFinishAll;
end;

TOBHideThread = class(TThread)
private
FExecuteEvent : TNotifyEventParams;
FParams : pointer;
public
constructor Create(event : TNotifyEventParams; params : pointer); virtual;
procedure Execute; override;
end;

procedure Synchronize(Method: TNotifyEvent);
procedure SynchronizeParams(Method: TNotifyEventParams; p : pointer);

implementation

var
mtx : THandle;

procedure Synchronize(Method : TNotifyEvent);
begin
WaitForSingleObject(mtx, INFINITE);
Method(nil);
ReleaseMutex(mtx);
end;

procedure SynchronizeParams(Method : TNotifyEventParams; p : pointer);
begin
WaitForSingleObject(mtx, INFINITE);
Method(nil, p);
ReleaseMutex(mtx);
end;

constructor TOBThread.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FThreadCount:=0;
FRunOnCreate:=true;
FExclusif:=true;
FreeOnTerminate:=true;
end;

destructor TOBThread.Destroy;
begin
inherited Destroy;
end;

function TOBThread.Execute(p : pointer):Thandle;
var
HideThread : TOBHideThread;
begin
result:=0;
if Assigned(FOnExecute) then
begin
if Exclusif then
if OneThreadIsRunning then exit;
inc(FThreadCount);
HideThread:=TOBHideThread.Create(FOnExecute, p);
HideThread.FreeOnTerminate:=FFreeOnTerminate;
HideThread.OnTerminate:=DoTerminate;
DoCreate;
if FRunOnCreate then
HideThread.Resume;
result:=HideThread.ThreadID;
end;
end;

function TOBThread.GetPriority(Thread:Thandle):TThreadPriority;
begin
result:=tpIdle;
if Thread<>0 then result:=TThreadPriority(GetThreadPriority(thread));
end;

procedure TOBThread.SetPriority(Thread:THandle;Priority:TThreadPriority);
begin
SetThreadPriority(Thread,integer(priority));
end;

procedure TOBThread.QuitThread(Thread:Thandle);
begin
TerminateThread(Thread,0);
end;

procedure TOBThread.Suspend(Thread:Thandle);
begin
SuspendThread(Thread);
end;

procedure TOBThread.Resume(Thread:Thandle);
begin
ResumeThread(thread);
end;

procedure TOBThread.DoCreate;
begin
if Assigned(FOnBegin) then
FOnBegin(nil);
end;

procedure TOBThread.DoTerminate;
begin
dec(FThreadCount);
if Assigned(FOnFinish) then
FOnFinish(nil);
if FThreadCount=0 then
if Assigned(FOnFinishAll) then
FOnFinishAll(nil);
end;

function TOBThread.OneThreadIsRunning : boolean;
begin
result:=FThreadCount>0;
end;




{*****************************************************}
constructor TOBHideThread.Create(event : TNotifyEventParams; params : pointer);
begin
inherited Create(true);
FExecuteEvent:=event;
FParams:=params;
end;
{*****************************************************}
procedure TOBHideThread.Execute;
begin
FExecuteEvent(nil, FParams);
end;
{*****************************************************}

initialization
mtx:=CreateMutex(nil, false, 'VCLJvThreadMutex');
finalization
CloseHandle(mtx);
end.

...全文
1581 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
在吗?http://bbs.csdn.net/topics/390574339 这个有没有完整的下载呢?
babydog01 2013-08-31
  • 打赏
  • 举报
回复
这个没有设备也白搭。可能不同的设备驱动,开发接口也不一样。
zhangzhen_927116 2013-08-30
  • 打赏
  • 举报
回复
[code=delphi]
unit IDCardDll_U;
interface

  function SDT_OpenPort(iPortID: Integer):integer;stdcall; //打开端口
  function SDT_ClosePort(iPortID: Integer):integer;stdcall;//关闭端口
  function SDT_PowerManagerBegin(iPortID,iIfOpen: Integer):integer;stdcall;
  function SDT_AddSAMUser(iPortID: Integer; pcUserName:string;iIfOpen: Integer):integer;stdcall;
  function SDT_SAMLogin(iPortID: Integer; pcUserName,pcPasswd: string ;iIfOpen: Integer):integer;stdcall;
  function SDT_SAMLogout(iPortID,iIfOpen: Integer):integer;stdcall;
  function SDT_UserManagerOK(iPortID,iIfOpen: Integer):integer;stdcall;
  function SDT_ChangeOwnPwd(iPortID: Integer; pcOldPasswd,pcNewPasswd: string; iIfOpen: Integer):integer;stdcall;
  function SDT_ChangeOtherPwd(iPortID: Integer; pcUserName, pcNewPasswd:string; iIfOpen:Integer):integer;stdcall;
  function SDT_DeleteSAMUser(iPortID: Integer; pcUserName: string; iIfOpen: Integer):integer;stdcall;
  function SDT_StartFindIDCard(iPortID: Integer;var pucIIN:Integer; iIfOpen: Integer):integer;stdcall;//查找卡
  function SDT_SelectIDCard(iPortID: Integer; var pucSN: Integer; iIfOpen: Integer):integer;stdcall;//再查找卡
  function SDT_ReadBaseMsg(iPortID: integer; pucCHMsg: string; varpuiCHMsgLen: Integer; pucPHMsg: string;var puiPHMsgLen: Integer; iIfOpen: Integer):integer;stdcall;
  function SDT_ReadBaseMsgToFile(iPortID: Integer; fileName1: string; var puiCHMsgLen: Integer; fileName2: string; var puiPHMsgLen: integer; iIfOpen: Integer):integer;stdcall;
  function SDT_WriteAppMsg(iPortID: Integer; var pucSendData: Byte; uiSendLen: Integer; var pucRecvData: Byte;var puiRecvLen: Integer;iIfOpen: Integer):integer;stdcall;
  function SDT_WriteAppMsgOK(iPortID: integer; var pucData: Byte;uiLen,iIfOpen: Integer):integer;stdcall;
  function SDT_CancelWriteAppMsg(iPortID, iIfOpen: integer):integer;stdcall;
  function SDT_ReadNewAppMsg(iPortID: integer;var pucAppMsg: Byte; var puiAppMsgLen: integer;iIfOpen: Integer):integer;stdcall;
  function SDT_ReadAllAppMsg(iPortID: Integer;var pucAppMsg: Byte; var puiAppMsgLen: Integer;iIfOpen: integer):integer;stdcall;
  function SDT_UsableAppMsg(iPortID: Integer;var ucByte: Byte; iIfOpen: Integer):integer;stdcall;
  function SDT_GetUnlockMsg(iPortID: Integer;var strMsg: Byte; iIfOpen: Integer):integer;stdcall;
  function SDT_GetSAMID(iPortID: Integer; var StrSAMID: Byte; iIfOpen: integer):integer;stdcall;
  function SDT_SetMaxRFByte(iPortID: Integer;ucByte: Byte; iIfOpen: Integer):integer;stdcall;
  function SDT_ResetSAM(iPortID: integer; iIfOpen: Integer):integer;stdcall;
  function GetBmp(file_name: string; intf: Integer):integer;stdcall;
  //-----------------------自定义函数-----------------------------------//
  function OpenUsbPort(var Port: Integer): Boolean; //打开USB端口
  function OPenComPort(var Port: Integer): Boolean;//打开Com端口
implementation
  function SDT_OpenPort; external 'Zsdtapi.dll';
  function SDT_ClosePort; external 'Zsdtapi.dll';
  function SDT_PowerManagerBegin; external 'Zsdtapi.dll';
  function SDT_AddSAMUser; external 'Zsdtapi.dll';
  function SDT_SAMLogin; external 'Zsdtapi.dll';
  function SDT_SAMLogout; external 'Zsdtapi.dll';
  function SDT_UserManagerOK;external 'Zsdtapi.dll';
  function SDT_ChangeOwnPwd;external 'Zsdtapi.dll';
  function SDT_ChangeOtherPwd;external 'Zsdtapi.dll';
  function SDT_DeleteSAMUser;external 'Zsdtapi.dll';
  function SDT_StartFindIDCard;external 'Zsdtapi.dll';
  function SDT_SelectIDCard;external 'Zsdtapi.dll';
  function SDT_ReadBaseMsg;external 'Zsdtapi.dll';
  function SDT_ReadBaseMsgToFile;external 'Zsdtapi.dll';
  function SDT_WriteAppMsg;external 'Zsdtapi.dll';
  function SDT_WriteAppMsgOK;external 'Zsdtapi.dll';
  function SDT_CancelWriteAppMsg;external 'Zsdtapi.dll';
  function SDT_ReadNewAppMsg;external 'Zsdtapi.dll';
  function SDT_ReadAllAppMsg;external 'Zsdtapi.dll';
  function SDT_UsableAppMsg;external 'Zsdtapi.dll';
  function SDT_GetUnlockMsg;external 'Zsdtapi.dll';
  function SDT_GetSAMID;external 'Zsdtapi.dll';
  function SDT_SetMaxRFByte;external 'Zsdtapi.dll';
  function SDT_ResetSAM;external 'Zsdtapi.dll';
  function GetBmp;external 'ZWltRS.dll';
 
  //-------------------------------自定义函数---------------//
function OpenUsbPort(var Port: Integer): Boolean;
var
  iPort,iRet: Integer;
begin
  Result:= False;
  for iPort:=1001 to 1016 do
  begin
    iRet:= SDT_OpenPort(iPort);
    if iRet=144 then
    begin
      Result:= True;
      Port:= iPort;
      Break;
    end;
  end;
end;

function OPenComPort(var Port: Integer): Boolean;//打开Com端口
var
  iPort,iRet: Integer;
begin
  Result:= False;
  for iPort:=1 to 10 do
  begin
    iRet:= SDT_OpenPort(iPort);
    if iRet=144 then
    begin
      Result:= True;
      Port:= iPort;
      Break;
    end;
  end;
end;


end.
[/code]
zhangzhen_927116 2013-08-30
  • 打赏
  • 举报
回复
unit IDCardClass_U;

interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;
type
  TIDCard = class(TObject)
  private
    FMZList: TStringList;//民族代码列表;
    FMZ: string;//民族
    FName:string;   //姓名
    FSex_Code: string;   //性别代码
    FSex_CName: string;   //性别
    FIDC: string;      //身份证号码
    FNATION_Code: string;   //民族代码
    FNATION_CName: string;   //民族
    FBIRTH: string;     //出生日期
    FADDRESS: string;    //住址
    FREGORG: string;     //签发机关
    FSTARTDATE: string;    //身份证有效起始日期
    FENDDATE: string;    //身份证有效截至日期
    FPeriod_Of_Validity_Code: string;   //有效期限代码,许多原来系统上面为了一代证考虑,常常存在这样的字段,二代证中已经没有了
    FPeriod_Of_Validity_CName: string;   //有效期限

    procedure SetMZ(value: string);
    procedure SetName(value: string);
    procedure SetSex_Code(value: string);
    procedure SetSex_CName(value: string);
    procedure SeTIDCardC(value: string);
    procedure SetNATION_Code(value: string);
    procedure SetNATION_CName(value: string);
    procedure SetBIRTH(value: string);
    procedure SetADDRESS(value: string);
    procedure SetREGORG(value: string);
    procedure SetSTARTDATE(value: string);
    procedure SetENDDATE(value: string);
    procedure SetPeriod_Of_Validity_Code(value: string);
    procedure SetPeriod_Of_Validity_CName(value: string);

    function GetMZ: string;
    function GetName: string;
    function GetSex_Code: string;
    function GetSex_CName: string;
    function GeTIDCardC: string;
    function GetNATION_Code: string;
    function GetNATION_CName: string;
    function GetBIRTH: string;
    function GetADDRESS: string;
    function GetREGORG: string;
    function GetSTARTDATE: string;
    function GetENDDATE: string;
    function GetPeriod_Of_Validity_Code: string;
    function GetPeriod_Of_Validity_CName: string;
  public
    constructor Create();
    destructor Destroy();
    procedure InitInfo(FileName: string);
    property MZ: string read GetMZ ;
    property Name: string read GetName write SetName;
    property Sex_Code: string read GetSex_Code write SetSex_Code;
    property Sex_CName: string read GetSex_CName write SetSex_CName;
    property IDC: string read GeTIDCardC write SeTIDCardC;
    property NATION_Code: string read GetNATION_Code write SetNATION_Code;
    property NATION_CName: string read GetNATION_CName write SetNATION_CName;
    property BIRTH: string read GetBIRTH write SetBIRTH;
    property ADDRESS: string read GetADDRESS write SetADDRESS;
    property REGORG: string read GetREGORG write SetREGORG;
    property STARTDATE: string read GetSTARTDATE write SetSTARTDATE;
    property ENDDATE: string read GetENDDATE write SetENDDATE;
    property Period_Of_Validity_Code: string read GetPeriod_Of_Validity_Code write SetPeriod_Of_Validity_Code;
    property Period_Of_Validity_CName: string read GetPeriod_Of_Validity_CName write SetPeriod_Of_Validity_CName;
  end;
implementation

{ TIDCard }
constructor TIDCard.Create;
begin
  inherited;
  //----------以下先后循序不能错-----------//
  FMZList:= TStringList.Create;
  FMZList.Add('汉族');
  FMZList.Add( '蒙古族');
  FMZList.Add('回族');
  FMZList.Add('藏族');
  FMZList.Add('维吾尔族');
  FMZList.Add('苗族');
  FMZList.Add('彝族');
  FMZList.Add('壮族');
  FMZList.Add('布依族');
  FMZList.Add('朝鲜族');
  FMZList.Add('满族');
  FMZList.Add('侗族');
  FMZList.Add('瑶族');
  FMZList.Add('白族');
  FMZList.Add('土家族');
  FMZList.Add('哈尼族');
  FMZList.Add('哈萨克族');
  FMZList.Add('傣族');
  FMZList.Add('黎族');
  FMZList.Add('傈僳族');
  FMZList.Add('佤族');
  FMZList.Add('畲族');
  FMZList.Add('高山族');
  FMZList.Add('拉祜族');
  FMZList.Add('水族');
  FMZList.Add('东乡族');
  FMZList.Add('纳西族');
  FMZList.Add('景颇族');
  FMZList.Add('柯尔克孜族');
  FMZList.Add('土族');
  FMZList.Add('达翰尔族');
  FMZList.Add('仫佬族');
  FMZList.Add('羌族');
  FMZList.Add('布朗族');
  FMZList.Add('撒拉族');
  FMZList.Add('毛南族');
  FMZList.Add('仡佬族');
  FMZList.Add('锡伯族');
  FMZList.Add('阿昌族');
  FMZList.Add('普米族');
  FMZList.Add('塔吉克族');
  FMZList.Add('怒族');
  FMZList.Add('乌孜别克族');
  FMZList.Add('俄罗斯族');
  FMZList.Add('鄂温克族');
  FMZList.Add('德昂族');
  FMZList.Add('保安族');
  FMZList.Add('裕固族');
  FMZList.Add('京族');
  FMZList.Add('塔塔尔族');
  FMZList.Add('独龙族');
  FMZList.Add('鄂伦春族');
  FMZList.Add('赫哲族');
  FMZList.Add('门巴族');
  FMZList.Add('珞巴族');
  FMZList.Add('基诺族');
  FMZList.Add('其它');
  FMZList.Add('外国人入籍')
end;

function TIDCard.GetADDRESS: string;
begin
  Result:= FADDRESS;
end;

function TIDCard.GetBIRTH: string;
begin
  Result:= FBIRTH;
end;

function TIDCard.GetENDDATE: string;
begin
  Result:= FENDDATE;
end;

function TIDCard.GeTIDCardC: string;
begin
  Result:= FIDC;
end;

function TIDCard.GetMZ: string;
begin
  Result:= FMZ;
end;

function TIDCard.GetName: string;
begin
  Result:= FName;
end;

function TIDCard.GetNATION_CName: string;
begin
  Result:= FNATION_CName;
end;

function TIDCard.GetNATION_Code: string;
begin
  Result:= FNATION_Code;
end;

function TIDCard.GetPeriod_Of_Validity_CName: string;
begin
  Result:= FPeriod_Of_Validity_CName;
end;

function TIDCard.GetPeriod_Of_Validity_Code: string;
begin
  Result:= FPeriod_Of_Validity_Code;
end;

function TIDCard.GetREGORG: string;
begin
  Result:= FREGORG;
end;

function TIDCard.GetSex_CName: string;
begin
  Result:= FSex_CName
end;

function TIDCard.GetSex_Code: string;
begin
  Result:= FSex_Code;
end;

function TIDCard.GetSTARTDATE: string;
begin
  Result:= FSTARTDATE;
end;

procedure TIDCard.SetADDRESS(value: string);
begin
  FADDRESS:= value;
end;

procedure TIDCard.SetBIRTH(value: string);
begin
  FBIRTH:= value;
end;

procedure TIDCard.SetENDDATE(value: string);
begin
  FENDDATE:= value;
end;

procedure TIDCard.SeTIDCardC(value: string);
begin
  FIDC:= value;
end;

procedure TIDCard.SetMZ(value: string);
begin
  FMZ:= value;
end;

procedure TIDCard.SetName(value: string);
begin
  FName:= value;
end;

procedure TIDCard.SetNATION_CName(value: string);
begin
  FNATION_CName:= value;
end;

procedure TIDCard.SetNATION_Code(value: string);
begin
  FNATION_Code:= value;
end;

procedure TIDCard.SetPeriod_Of_Validity_CName(value: string);
begin
  FPeriod_Of_Validity_CName:= value;
end;

procedure TIDCard.SetPeriod_Of_Validity_Code(value: string);
begin
  FPeriod_Of_Validity_Code:= value;
end;

procedure TIDCard.SetREGORG(value: string);
begin
  FREGORG:= value;
end;

procedure TIDCard.SetSex_CName(value: string);
begin
  FSex_CName:= value;
end;

procedure TIDCard.SetSex_Code(value: string);
begin
  FSex_Code:= value;
end;

procedure TIDCard.SetSTARTDATE(value: string);
begin
  FSTARTDATE:= value;
end;

procedure TIDCard.InitInfo(FileName: string);
var
  iFileHandle,iFileLength: Integer;
  Buffer: PWideChar;
  wInfo :WideString;
begin
  iFileHandle := FileOpen(FileName, fmOpenRead);
  iFileLength := FileSeek(iFileHandle,0,2);
  FileSeek(iFileHandle,0,0);
  Buffer := PWideChar(AllocMem(iFileLength +2));
  FileRead(iFileHandle, Buffer^, iFileLength);
  FileClose(iFileHandle);
  wInfo:=WideChartostring(buffer);
  SetName(trim(copy(wInfo,1,15)));
  SetSex_Code(trim(copy(wInfo,16,1)));
  if FSex_Code = '1' then
    SetSex_CName('男')
  else if FSex_Code = '2' then
    SetSex_CName('女');
  SetNATION_Code(trim(copy(wInfo,17,2)));
  if FMZList<> nil then
    SetNATION_CName(FMZList.Strings[StrToInt(FNATION_Code)-1]);
  SetBIRTH(trim(copy(wInfo,19,8)));
  SetADDRESS(trim(copy(wInfo,27,35)));
  SeTIDCardC(trim(copy(wInfo,62,18)));
  SetREGORG(trim(copy(wInfo,80,15)));
  SetSTARTDATE(trim(copy(wInfo,95,8)));
  SetENDDATE(trim(copy(wInfo,103,8)));
end;


destructor TIDCard.Destroy;
begin
  FMZList.Free;
end;

end.

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧