📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
SB: TStatusBar;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
TabSheet6: TTabSheet;
opencomm: TButton;
closecomm: TButton;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label7: TLabel;
CBPort: TComboBox;
CBRaudRate: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
Timer1: TTimer;
Button1: TButton;
Label3: TLabel;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
GroupBox1: TGroupBox;
Button2: TButton;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
CB1: TComboBox;
Edit5: TEdit;
Edit6: TEdit;
CheckBox1: TCheckBox;
GroupBox2: TGroupBox;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Button3: TButton;
ComboBox1: TComboBox;
Edit7: TEdit;
Edit8: TEdit;
Label16: TLabel;
ComboBox2: TComboBox;
Label17: TLabel;
ComboBox6: TComboBox;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Edit9: TEdit;
GroupBox3: TGroupBox;
Label21: TLabel;
Button4: TButton;
ComboBox7: TComboBox;
Label22: TLabel;
CB2: TComboBox;
Label23: TLabel;
GroupBox4: TGroupBox;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Button5: TButton;
ComboBox8: TComboBox;
Edit10: TEdit;
Edit11: TEdit;
ComboBox9: TComboBox;
GroupBox5: TGroupBox;
Label29: TLabel;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
Label33: TLabel;
Label34: TLabel;
Label36: TLabel;
Button9: TButton;
ComboBox10: TComboBox;
Edit12: TEdit;
Edit13: TEdit;
ComboBox11: TComboBox;
ComboBox12: TComboBox;
Edit14: TEdit;
Label37: TLabel;
Label38: TLabel;
Label39: TLabel;
Label40: TLabel;
ComboBox15: TComboBox;
Label41: TLabel;
EdtTimeOut: TEdit;
CheckBox2: TCheckBox;
ComboBox13: TComboBox;
ComboBox14: TComboBox;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Label42: TLabel;
Edit16: TEdit;
ComboBox16: TComboBox;
GroupBox6: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button10: TButton;
Label35: TLabel;
cardNo: TEdit;
CheckBox3: TCheckBox;
Function HexToDec(data: String): Integer;
procedure opencommClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure closecommClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ComboBox7Change(Sender: TObject);
procedure ComboBox16Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
PassFlag : boolean;
//政通金属键盘动态连接库引用
Function ZT_EPP_OpenCom(Port,BaudRate:integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_CloseCom():integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinInitialization(iInitMode :integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinReadVersion(Version,SN,Rechang: PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_SetDesPara(P,F:integer):integer;stdcall;external'ZT_EPP_API.dll';
//Function ZT_EPP_PinLoadMasterKey(iMKMode,MKeyNo:integer;MKeyAsc:PByte;cpAuth:PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinLoadMasterKey(iMKMode,MKeyNo:integer;MKeyAsc:PChar;cpAuth:PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinLoadWorkKey(iMKMode,MKeyNo,WKeyNo:integer ;MKeyAsc:PChar; cpAuth:PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_ActivWorkPin( MKeyNo,WKeyNo:integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinLoadCardNo(pCardNo: PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_OpenKeyVoic(CTL:integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinStartAdd(PinLen,DispMode,AddMode,PromMode,TimeOut :integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinReportPressed(chKey : PChar;iTimeOut :integer):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinReadPin( iWKMode:integer ; chPin :PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinCalMAC(iWKMode,iMacMode:integer; chString,chMAC : PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinAdd(iWKMode,iMode:integer; chPinData,chPinOut : PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_PinUnAdd(iWKMode,iMode:integer; chInData ,chOutData : PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_Undes(DataInput,key,DataOutput : PChar):integer;stdcall;external'ZT_EPP_API.dll';
Function ZT_EPP_Des(DataInput,key,DataOutput: PChar ):integer;stdcall;external'ZT_EPP_API.dll';
procedure ZT_EPP_DllSplitBcd(CharBcd,CharAsc : PChar; BcdLen :integer);stdcall;external'ZT_EPP_API.dll';
implementation
{$R *.dfm}
Function TForm1.HexToDec(data: String): Integer;
var
h1,h2,count: Integer;
c1,c2: Char;
begin
data := LowerCase(data);
count := length(data);
if count= 1 then
begin
c1 := '0';
c2 := data[1]; //只输入一位数
end
else
begin
c1 := data[1]; //输入几位数,只要前两位
c2 := data[2];
end;
Case c1 of
'a': h1 := 10;
'b': h1 := 11;
'c': h1 := 12;
'd': h1 := 13;
'e': h1 := 14;
'f': h1 := 15;
else
h1 := strtoint(c1);
end;
Case c2 of
'a': h2 := 10;
'b': h2 := 11;
'c': h2 := 12;
'd': h2 := 13;
'e': h2 := 14;
'f': h2 := 15;
else
h2 := strtoint(c2);
end;
hextodec := h1*16+h2;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
sb.Panels[1].Text := '状态';
sb.Panels[2].Text := '先打开串口';
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
sb.Panels[0].Text := timetoStr(now());
end;
procedure TForm1.opencommClick(Sender: TObject); //打开串口按键
var
Port,BaudRate,Ret : integer;
begin
Port := StrToInt(CBPort.Items[CBPort.ItemIndex]);
BaudRate := StrToInt(CBRaudRate.Items[CBRaudRate.ItemIndex]);
Ret := ZT_EPP_OpenCom(Port, BaudRate); //COM1
if Ret=0 then
begin
sb.Panels[2].Text := '成功打开串口';
end;
end;
procedure TForm1.closecommClick(Sender: TObject); //关闭串口按键
var
Ret : integer;
begin
Ret := ZT_EPP_CloseCom(); //COM1
if Ret=0 then
begin
sb.Panels[2].Text := '关闭串口成功';
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ZT_EPP_CloseCom();
end;
procedure TForm1.Button1Click(Sender: TObject); //读取版本按键
var
Ret : Integer;
Version,SN,Rechang : array [0..4095] of char;
begin
Ret := ZT_EPP_PinReadVersion(Version,SN,Rechang);
if Ret=0 then
begin
Edit1.Text := Version;
Edit2.Text := SN;
Edit2.Text := copy(SN,1,4);
Edit3.Text := copy(SN,5,4);;
Edit4.Text := Rechang;
sb.Panels[2].Text := '读取版本信息成功';
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
var
i : integer;
begin
if CheckBox1.Checked then
begin
Label22.Visible := True;
CB2.Visible := True;
Label23.Visible := True;
CB1.Clear;
for i:=64 to 79 do //0x40--04F
begin
CB1.Items.Add(inttohex(i,1));
end;
CB1.ItemIndex :=0;
end
else
begin
Label22.Visible := False;
CB2.Visible := False;
Label23.Visible := False;
CB1.Clear;
for i:=0 to 15 do
begin
CB1.Items.Add(inttohex(i,1));
end;
CB1.ItemIndex :=0;
end;
end;
procedure TForm1.ComboBox7Change(Sender: TObject);
begin
if ComboBox7.ItemIndex=0 then
begin
Label21.Caption :='键盘初始化,不清除密钥';
end
else
begin
Label21.caption :='键盘初始化,清除所有密钥';
end;
end;
procedure TForm1.ComboBox16Change(Sender: TObject);
begin
case ComboBox16.ItemIndex of
0 : Edit14.Text :='1表示X9.9/X9.19算法!';
1 : Edit14.Text :='2表示SAM卡算法!';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -