library pxxie_ka1;
{ 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
SysUtils,
Classes;
{$R *.res}
function ic_init(port: smallint;baud: longint): longint; stdcall;
far;external 'Mwic_32.DLL' name 'ic_init';
function ic_exit(icdev: longint):smallint;stdcall;
far;external 'Mwic_32.dll' name 'ic_exit';
function dv_beep(icdev: longint;time:smallint):smallint;stdcall;
far;external 'Mwic_32.dll'name 'dv_beep';
function get_status(icdev: longint;status:pchar):smallint;stdcall;
far;external 'Mwic_32.dll' name 'get_status';
function swr_4442(icdev: longint;offset:smallint;length:smallint;data1:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'swr_4442';
function swr_4442_hex(icdev: longint;offset:smallint;length:smallint;data1:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'swr_4442';
function srd_4442(icdev: longint;offset:smallint;length:smallint; data1:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'srd_4442';
function chk_4442(icdev: longint):smallint;stdcall;
far;external 'Mwic_32.dll'name 'chk_4442';
function csc_4442(icdev: longint;length:smallint;password:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'csc_4442';
function wsc_4442(icdev: longint;length:smallint; password:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'wsc_4442';
function rsct_4442(icdev: longint;counter:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'rsct_4442';
function asc_hex(asc:pchar;hex:pchar;len:longint):smallint;stdcall;
far;external 'Mwic_32.dll'name 'asc_hex';
function hex_asc(hex:pchar;asc:pchar;len:longint):smallint;stdcall;
far;external 'Mwic_32.dll'name 'hex_asc';
function ic_encrypt(key:pchar;source:pchar;len:smallint;dest:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'ic_encrypt';
function ic_decrypt(key:pchar;dest:pchar;len:smallint;source:pchar):smallint;stdcall;
far;external 'Mwic_32.dll'name 'ic_decrypt';
var
icdev:longint;
st:smallint;
status:smallint;
//password:array[0..5]of char;
passwordhex:array[0..3]of char;
data1:array[0..20] of char;
function px_init(port: smallint;baud: longint): integer; stdcall;
begin
begin
icdev:=ic_init(port,baud);
if icdev<=0 then
result:=1
//messagebox(0,'','',mb_ok)
else
result:=0;
st:=dv_beep(icdev,20) ;
end;
begin
status :=0;
st:=get_status(icdev,@status); //檢測讀寫器中是否有卡,status=1 有卡
if st<>0 then
result:=1 //讀卡器連接失敗
else
if status=0 then
result:=2 ; //無卡
end;
begin
st:=chk_4442(icdev);
if st<>0 then
result:=1 //非4442卡
else
result:=0 ;
end;
begin
st:=asc_hex('ffffff',passwordhex,6);
st:=csc_4442(icdev,3,passwordhex);
if st<>0 then
result:=3 //密碼錯誤
else
result:=0;
end;
begin
data1:=chr($ff)+chr($ff)+chr($ff);
st:=swr_4442_hex(icdev,40,3,data1);
if st<>0 then
result:=4 //寫卡失敗
else
result:=0;
end;
end;
exports
px_init;
begin
end.
uj5u.com熱心網友回復:
什么問題?
uj5u.com熱心網友回復:
明華接觸式ic卡對接,看起來沒啥錯誤uj5u.com熱心網友回復:
{$R *.res}去掉far;去掉,這是16位時代的東西
begin //去掉
end. //保留
uj5u.com熱心網友回復:
能不能把我寫的改下,重新發給我行不,uj5u.com熱心網友回復:
我見過的密碼從來都是6位元組的,轉為16進制字串就是12位元組。注意你的'ffffff'轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/53675.html
標籤:VCL組件開發及應用
