Home > Back-end >  C code translation problems. About the DLL function is used, please help convert delphi7 code
C code translation problems. About the DLL function is used, please help convert delphi7 code

Time:11-11

/*
COMID serial number
CardID IC card number;
Residual gas inside CardGas card;
IcNum for issuing number
IcMark for card note
Passbuf for the encrypted information, 128
*/

Int __stdcall Bank_Read (int COMID, char * cardid, int * cardgas, int * icnum, int * icmark, char * passBuff);
Int __stdcall Bank_Write (int COMID, cardid char * and an int cardgas, char * passbuf);


* * * * * * * * * * above is manufacturer to C code, the dynamic library function call a method of * * * * * * * * * *

//the following is my try writing Delphi7 call code,

The function HYYTReadCard (COMID: Integer; CardID: PAnsiChar; Var CardGas: Integer; Var IcNum IcMark: Integer; Password: PAnsiChar) : Integer; Stdcall;
The function HYYTWriteCard (COMID: Integer; CardID: PAnsiChar; Var CardGas: Integer; Password: PAnsiChar) : Integer; Stdcall;
The function HYYTReadCard; External 'HYYT_Card. DLL' name 'Bank_Read';
The function HYYTWriteCard; External 'HYYT_Card. DLL' name 'Bank_Write';

Procedure TYzqtMainForm. Btn2Click (Sender: TObject);//- card read
Var
GStat1: integer;
COMID: integer;//serial number, 1 to 0
CardID: an array of char [1.. 10];//card number
CardGas: integer;//card within allowance
IcNum: integer;//card number
IcMark: integer;//note information
Password: an array of char [1.. 128];//card tight
The begin
GStat1:=HYYTReadCard (COMID, @ CardID, CardGas IcNum, IcMark, @ ");
If gStat1=0 then
The begin
Showmessage (' card read success! ');
//showmessage (inttostr (ICErroy) + ', '+ trim (ErroyMsg));
Showmessage (' @ # serial comm: @ + inttostr (COMID) + '@');
Showmessage (' @ @ user card number + CardID + '@');
Showmessage (' @ Kane allowance @ + inttostr (CardGas) + '@ @');
Showmessage (' @ card number @ + inttostr (IcNum) + '@ @');
Showmessage (' @ issuing note @ + inttostr (IcMark) + '@ @');
Edt1. Text:=trim (password);
end;
end;
The problem is, in addition to the password: an array of char [1.. 128].//card close this one to obtain the data, the other fields are not data, are 0 or null, CardID USES this parameter should be and the dense, but also no data, CardGas, IcNum, whether there is a problem, the definition of IcMark unclear pointer accurate definition, hope to get advice, how to translate the two lines of code of manufacturer,

CodePudding user response:

The function HYYTReadCard (COMID: Integer; CardID: PAnsiChar; Var CardGas IcNum, IcMark: Integer; Password: PAnsiChar) : Integer; Stdcall; External 'HYYT_Card. DLL' name 'Bank_Read';
The function HYYTWriteCard (COMID: Integer; CardID: PAnsiChar; CardGas: Integer; Password: PAnsiChar) : Integer; Stdcall; External 'HYYT_Card. DLL' name 'Bank_Write';

CodePudding user response:

 
Procedure TYzqtMainForm. Btn2Click (Sender: TObject);//- card read
Var
GStat1: integer;
COMID: integer;//serial number, 1 to 0
CardID: array [0.. 9] of char;//card number
CardGas: integer;//card within allowance
IcNum: integer;//card number
IcMark: integer;//note information
Password: an array of char [0.. 127];//card tight
The begin
GStat1:=HYYTReadCard (COMID, CardID, CardGas IcNum, IcMark, password);
If gStat1=0 then
The begin
Showmessage (' card read success! ');
//showmessage (inttostr (ICErroy) + ', '+ trim (ErroyMsg));
Showmessage (' @ # serial comm: @ + inttostr (COMID) + '@');
Showmessage (' @ @ user card number + CardID + '@');
Showmessage (' @ Kane allowance @ + inttostr (CardGas) + '@ @');
Showmessage (' @ card number @ + inttostr (IcNum) + '@ @');
Showmessage (' @ issuing note @ + inttostr (IcMark) + '@ @');
Edt1. Text:=trim (password);
end;
end;
  • Related