Home > Back-end >  Help write DLL error
Help write DLL error

Time:09-19

The library pxxie_ka1;

{Important note about DLL memory management: ShareMem must be the
The first unit in your library 's USES clause AND your project' s (select
The Project - the View Source) USES clause if your DLL exports any procedures or
Functions provides 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 get the using BORLNDMM. DLL, pass the string information
Using PChar or ShortString parameters.}

USES the
SysUtils,
Classes;

{$R *. Res}
The function ic_init (port: smallint, Baud: longint) : longint; Stdcall;
Far; External 'Mwic_32. DLL' name 'ic_init';

The function ic_exit (icdev: longint) : smallint; Stdcall;
Far; External 'Mwic_32. DLL' name 'ic_exit';

The function dv_beep (icdev: longint; Time: smallint) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'dv_beep';

The function get_status (icdev: longint; Status: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'get_status';

The function swr_4442 (icdev: longint; Offset: smallint, Length: smallint; Data1: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'swr_4442';

The function swr_4442_hex (icdev: longint; Offset: smallint, Length: smallint; Data1: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'swr_4442';

The function srd_4442 (icdev: longint; Offset: smallint, Length: smallint; Data1: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'srd_4442';

The function chk_4442 (icdev: longint) : smallint; Stdcall;
Far; External 'Mwic_32. DLL' name 'chk_4442';

The function csc_4442 (icdev: longint; Length: smallint; Password: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'csc_4442';

The function wsc_4442 (icdev: longint; Length: smallint; Password: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'wsc_4442';

The function rsct_4442 (icdev: longint; Counter: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'rsct_4442';

The function asc_hex (asc: pchar; Hex: pchar; Len: longint) : smallint; Stdcall;
Far; External 'Mwic_32. DLL' name 'asc_hex';

The function hex_asc (hex: pchar; Asc: pchar; Len: longint) : smallint; Stdcall;
Far; External 'Mwic_32. DLL' name 'hex_asc';

The function ic_encrypt (key: pchar; Source: pchar; Len: smallint, Dest: pchar) : smallint, Stdcall;
Far; External 'Mwic_32. DLL' name 'ic_encrypt';

The 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;



The function px_init (port: smallint, Baud: longint) : integer; Stdcall;
The begin
The begin
Icdev:=ic_init (port, baud);
If icdev<=0 then
Result:=1

//messagebox (0, ' ', ' ', mb_ok)

The else
Result:=0;
St:=dv_beep (icdev, 20);
end;
The begin

Status:=0;
St:=get_status (icdev, @ status);//detection, speaking, reading and writing, whether has the card status=1 has card
If st<> 0 then
Result:=1//card reader connection failure
The else
If the status=0 then
Result:=2;//no card
end;
The begin
St:=chk_4442 (icdev);
If st<> 0 then
Result:=1//4442 card
The else
Result:=0;
end;
The begin

St:=asc_hex (" FFFFFF "passwordhex, 6);
St:=csc_4442 (icdev, 3, passwordhex);
If st<> 0 then
Result:=3//password error
The else
Result:=0;
end;

The begin
Data1:=CRH ($ff) + CRH ($ff) + CRH ($ff);
St:=swr_4442_hex (icdev, 40, 3, data1);
If st<> 0 then
Result:=4//write card failure
The else
Result:=0;
end;

end;

Exports
Px_init;

The begin
end.

CodePudding user response:

What's the problem?

CodePudding user response:

Minghua docking non-contact IC card, it seems that nothing wrong

CodePudding user response:

{$R *. Res} to remove
Far; Take out, this is what 16 times
The begin//remove
End.//keep

CodePudding user response:

Can you write me the change, not resend to our bank,

CodePudding user response:

I've seen password has always been 6 bytes, converted to hexadecimal string is 12 bytes, pay attention to your "FFFFFF"
  • Related