📄 mf500_hy60.dpr
字号:
library MF500_HY60;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
Windows,
Messages,
SysUtils,
ComCtrls,
ExtCtrls,
StdCtrls,
Controls,
Classes,
Dialogs,
PublicUnitForCall in 'PublicUnitForCall.pas';
{$R *.res}
function Com_Close:integer;stdcall;
begin
if SetComPortStateBool=false then
begin
result:=1;
exit;
end
else
begin
closeHandle(hComm);
purgecomm( hComm,PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR);
result:=0;
end;
end;
function Com_Open(ComPortSet_PortString:string;RegComPortSet_BaudRate:integer):boolean;stdcall;
var
ComConfi : TCOMMCONFIG;
begin
if(hComm<>0) then
CloseHandle(hComm);
hComm:=CreateFile(PChar(ComPortSet_PortString),GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING,0,0);
if(hComm=INVALID_HANDLE_VALUE) then
begin
result:= false;
SetComPortStateBool:=false;
ShowMessage('串口设置失败,请您重新进行串口设置!');
exit;
end;
GetCommState(hComm,ComConfi.DCB);
ComConfi.dcb.BaudRate:=RegComPortSet_BaudRate;
//设置检验位
ComConfi.dcb.Parity:=0;
//设置数据位
ComConfi.dcb.ByteSize:=8;
//设置停止位
ComConfi.dcb.StopBits:=0;
if not SetCommState(hComm,ComConfi.dcb) then
begin
result:= false;
SetComPortStateBool:=false;
ShowMessage('串口设置失败,请您重新进行串口设置!');
closeHandle(hComm);
exit;
end
else
begin
result:=ReadPassWordOK('AABB0474032152','AABB0D7441757468206279204C696E01');
if result then
SetComPortStateBool:=true
else
SetComPortStateBool:=false;
end;
IniReadCommandDataArrayString;
end;
function HardWare_Version(out HDver:string):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
HDver:=(HexToChar(ReadDataFromCardForShow(0,'')));
result:=(ReturnReadDataState); //固件版本
end;
//天线操作
function Antenna_Control(switch:integer):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
if switch=1 then
ReadDataFromCardForState(1,'开启天线:')
else
ReadDataFromCardForState(2,'关闭天线:');
result:=ReturnReadDataState;
end;
function RF_M1_Halt:integer;stdcall;
begin
GivenDelayTimeForDll:=30;
ReadDataFromCardForState(3,'卡休眠操作:');
result:=ReturnReadDataState;
end;
function AutoSearch_Card(switch:integer):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
if switch=1 then
ReadDataFromCardForState(4,'开启自动寻卡:')
else
ReadDataFromCardForState(5,'关闭自动寻卡:');
result:=ReturnReadDataState;
end;
function Beep_Shuffle(switch:integer):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
if switch=1 then
ReadDataFromCardForState(6,'开启蜂鸣器:')
else
ReadDataFromCardForState(7,'关闭蜂鸣器:');
result:=ReturnReadDataState;
end;
function RF_M1_CardType(out CardType:string):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
CardType:=pchar(ReadDataFromCardForShow(8,''));
result:=ReturnReadDataState;
end;
function RF_M1_SerialNo(out CardSN:string):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
CardSN:=ReadDataFromCardForShow(9,'');
result:=ReturnReadDataState;
end;
function RF_M1_PassLoad(KeyType:string;Block:integer;Key:string):integer;stdcall;
begin
GivenDelayTimeForDll:=50;
WriteDadaToCardFunction('下载密码',10,KeyType+inttohex(Block,2),Key,6*2);
result:=ReturnReadDataState;
end;
function RF_M1_VerifyPassword(KeyType:string;Block:integer):integer;stdcall;
var
ReadCardNumberString:String;
begin
GivenDelayTimeForDll:=50;
ReadCardNumberString:=ReadDataFromCardForShow(9,'');
if ReadCardNumberString='' then
exit;
WriteDadaToCardFunction('校验密码',11,KeyType,ReadCardNumberString+inttohex(Block,2),5*2);
result:=ReturnReadDataState;
end;
function RF_M1_ChangePassword(Block:integer;PasswordA,ControlPassword,PasswordB:string):integer;stdcall;
var
WriteStrtoCardPassword:String;
begin
GivenDelayTimeForDll:=50;
WriteStrtoCardPassword:=PasswordA+ControlPassword+PasswordB;
WriteDadaToCardFunction('修改密码',13,inttohex(Block,2),WriteStrtoCardPassword,16*2);
result:=ReturnReadDataState;
end;
function RF_M1_Purse_Init(Block:integer;InitValue:single):integer;stdcall;
begin
GivenDelayTimeForDll:=40;
WriteMoneyToCardFunction('初始化钱包',14,inttohex(Block,2),ReverseHexStr(inttohex((round(InitValue*100)),8)));
result:=ReturnReadDataState;
end;
function RF_RF_M1_Purse_Increment(Block:integer;IncValue:single):integer;stdcall;
begin
GivenDelayTimeForDll:=40;
WriteMoneyToCardFunction('钱包充值操作',16,inttohex(Block,2),ReverseHexStr(inttohex((round(IncValue*100)),8)));
result:=ReturnReadDataState;
end;
function RF_M1_Purse_Decrement(Block:integer;DecValue:single):integer;stdcall;
begin
GivenDelayTimeForDll:=40;
WriteMoneyToCardFunction('钱包扣款操作',17,inttohex(Block,2),ReverseHexStr(inttohex((round(DecValue*100)),8)));
result:=ReturnReadDataState;
end;
function RF_M1_Purse_Read(Block:integer;out ReadValue:string):integer;stdcall;
begin
GivenDelayTimeForDll:=40;
ReadValue:=FormatFloat('#0.##',(Hex_Int(ReverseHexStr(ReadDataFromCardForShow(15,inttohex(Block,2))))/100));
result:=ReturnReadDataState; //读取钱包值
end;
function RF_M1_Block_Read(Block:integer;out ReadBlock:string):integer;stdcall;
begin
GivenDelayTimeForDll:=70;
ReadBlock:=pchar(ReadDataFromCardForShow(12,inttohex(Block,2)));
result:=ReturnReadDataState; //读取块值
end;
function RF_M1_Block_Write(Block:integer;WriteBlockHex:string):integer;stdcall;
begin
GivenDelayTimeForDll:=70;
WriteDadaToCardFunction('写块操作',13,inttohex(Block,2),WriteBlockHex,16*2);
result:=ReturnReadDataState;
end;
function LED_Display(Digital_str:string):integer;stdcall;
var
ShowNum,i:integer;
ShowNumHex:string;
begin
GivenDelayTimeForDll:=40;
WriteDadaToCardFunction('LED显示',18,'',LEDStrProcess(Digital_str),8*2);
i:=pos('.',Digital_str);
if i>0 then
begin
if i=1 then
Digital_str:='0'+Digital_str;
ShowNum:=Length(Digital_str)-1;
end
else
begin
ShowNum:=Length(Digital_str);
end;
case ShowNum of
1: ShowNumHex:='01';
2: ShowNumHex:='03';
3: ShowNumHex:='07';
4: ShowNumHex:='0F';
5: ShowNumHex:='1F';
6: ShowNumHex:='3F';
7: ShowNumHex:='7F';
8: ShowNumHex:='FF';
END;
WriteDadaToCardFunction('',19,'',ShowNumHex,1*2);
result:=ReturnReadDataState;
end;
function LED_Hide:integer;stdcall;
begin
GivenDelayTimeForDll:=30;
ReadDataFromCardForState(19,'LED消隐:');
result:=ReturnReadDataState;
end;
function LED_Reset:integer;stdcall;
begin
GivenDelayTimeForDll:=30;
ReadDataFromCardForState(20,'LED复位:');
result:=ReturnReadDataState;
end;
function LED_Shift_Left_Cycle:integer;stdcall;
begin
GivenDelayTimeForDll:=60;
ReadDataFromCardForState(24,'LED左循环:');
result:=ReturnReadDataState;
end;
function LED_Shift_Left:integer;stdcall;
begin
GivenDelayTimeForDll:=2000;
ReadDataFromCardForState(26,'LED不左循环:');
result:=ReturnReadDataState;
end;
function LED_Shift_Right_Cycle:integer;stdcall;
begin
GivenDelayTimeForDll:=2000;
ReadDataFromCardForState(25,'LED右循环:');
result:=ReturnReadDataState;
end;
function LED_Shift_Right:integer;stdcall;
begin
GivenDelayTimeForDll:=2000;
ReadDataFromCardForState(27,'LED不右循环:');
result:=ReturnReadDataState;
end;
function LCD_Reset:integer;stdcall;
begin
GivenDelayTimeForDll:=30;
ReadDataFromCardForState(28,'LCD清屏:');
result:=ReturnReadDataState;
end;
function LCD_String_Display(X,Y,LCDShowHexStr:string):integer;stdcall;
begin
GivenDelayTimeForDll:=60;
WriteDadaToCardFunction('LCD显示',29,'',X+Y+LCDShowHexStr,4+Length(LCDShowHexStr));
result:=ReturnReadDataState;
end;
function LCD_Backlight(switch:integer):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
if switch=1 then
ReadDataFromCardForState(30,'启动LCD背光:')
else
ReadDataFromCardForState(31,'关闭LCD背光:');
result:=ReturnReadDataState;
end;
function Device_PartNumber(out PartNumber:string):integer;stdcall;
begin
GivenDelayTimeForDll:=30;
PartNumber:=HexToChar(ReadDataFromCardForShow(37,''));
result:=ReturnReadDataState; //设备型号
end;
exports
Com_Open,Com_Close index 1, //串口设置操作
HardWare_Version index 2, //读固件版本号
Antenna_Control index 3, // 天线控制(1开 0关)
RF_M1_Halt index 4 , //无数据卡休眠操作
AutoSearch_Card index 5, //开启自动寻卡 (1开 0关)
Beep_Shuffle index 6, //蜂鸣器操作(1开 0关)
RF_M1_CardType index 7, //读卡类型
RF_M1_SerialNo index 8, //读取卡序列号
RF_M1_PassLoad index 9, //下载密码
RF_M1_VerifyPassword index 10, //校验密码 ?
RF_M1_ChangePassword index 11, //修改密码 ?
RF_M1_Purse_Init index 12, //初始化钱包
RF_RF_M1_Purse_Increment index 13, //钱包充值操作
RF_M1_Purse_Decrement index 14, //钱包扣款操作
RF_M1_Purse_Read index 15, //读取钱包
RF_M1_Block_Read index 16, //读块值
RF_M1_Block_Write index 17, //写块值
LED_Display index 18, //LED显示
LED_Reset index 19, //LED复位
LED_Hide index 20, //LED消隐
LED_Shift_Left_Cycle index 21, //LED左循环
LED_Shift_Left index 22, //LED不左循环
LED_Shift_Right_Cycle index 23, //LED右循环
LED_Shift_Right index 24, //LED不右循环
LCD_Reset index 25, //LCD清屏
LCD_String_Display index 26, //LCD显示
LCD_Backlight index 27, //LCD背光 操作 (1开 0关)
Device_PartNumber index 28; //读取设备型号
begin
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -