Home > Back-end >  Delphi 7 C call interface API DLL function with structure problem?
Delphi 7 C call interface API DLL function with structure problem?

Time:09-16

Written in C API DLL interface file
This is the header file, how to rewrite in Delphi and call this a few interface function? Urgent help Daniel?
 
# # ifndef _OPENAPI_H_
# define _OPENAPI_H_
#include



Typedef struct t8583
{
Char m_acTermCode [16].//terminal number
Char m_acTraceSerial [7].//terminal serial number, fixed-length six, not left to fill 0 and in the same day are not allowed to repeat the
Char m_acAmount [13].//amount, unit points, fixed-length 12, not left to fill 0
Char m_acRespCode [4].//the response code
Char m_acNonceStr [20].//retrieve reference number
Char m_acPrivate [1000].//private message data fields
Char m_acAddition [1000].//message additional data fields
Char m_acDetail [1000].//message data detail domain
T8583 ()
{
Memset (m_acTermCode, 0, sizeof (m_acTermCode));
Memset (m_acTraceSerial, 0, sizeof (m_acTraceSerial));
Memset (m_acAmount, 0, sizeof (m_acAmount));
Memset (m_acRespCode, 0, sizeof (m_acRespCode));
Memset (m_acNonceStr, 0, sizeof (m_acNonceStr));
Memset (m_acPrivate, 0, sizeof (m_acPrivate));
Memset (m_acAddition, 0, sizeof (m_acAddition));
Memset (m_acDetail, 0, sizeof (m_acDetail));
}
} t8583;

//# define GRGOPENAPI
# define GRGOPENAPI _declspec (dllexport)

/*! \ brief, this is the sign in play to unpack the interface function called
\ param data into the data storage structure refs
\ param MSG and store the converted 8583 message
\ param msgLen out and store the converted 8583
the length of the message\ return Boolean values
- true success
- false failure, parameter is not correct, or data wrong
\ note data incoming sample format to see
*/
GRGOPENAPI bool bPackSignin8583 (const t8583 & amp; Data, unsigned char * MSG, int& MsgLen);


/*! \ brief, this is the sign in play to unpack the interface function called
\ param data out and storage structure of data
\ param MSG into the storage network receives 8583 refs message
\ param msgLen into the storage network receives 8583 refs packet length
\ return Boolean values
- true success
- false failure, parameter is not correct, or data wrong
\ note data incoming sample format to see
*/
GRGOPENAPI bool bUnpackSignin8583 (t8583 & amp; The data, const unsigned char * MSG, int& MsgLen);


/*! \ brief, this is the sign back pack interface function called
\ param data into the data storage structure refs
\ param MSG and store the converted 8583 message
\ param msgLen out and store the converted 8583
the length of the message\ return Boolean values
- true success
- false failure, parameter is not correct, or data wrong
\ note data incoming sample format to see
*/
GRGOPENAPI bool bPackSignout8583 (const t8583 & amp; Data, unsigned char * MSG, int& MsgLen);


/*! \ brief, this is the sign back to unpack the interface function called
\ param data out and storage structure of data
\ param MSG into the storage network receives 8583 refs message
\ param msgLen into the storage network receives 8583 refs packet length
\ return Boolean values
- true success
- false failure, parameter is not correct, or data wrong
\ note introduced to format data view example



CodePudding user response:


 unit _8583 

Interface

Const

DLLNAME='your DLL name'

Type
T8583=record
M_acTermCode=array [0.. 15] of char;
M_acTraceSerial=array [0.. 6] of char.
M_acAmount=array [0.. 12] of char;
M_acRespCode=array [0.. 3] of char.
19] m_acNonceStr=array [0.. of char;
M_acPrivate=array [0.. 999] of char.
M_acAddition=array [0.. 999] of char.
M_acDetail=array [0.. 999] of char.
end;
Implementation
The function bPackSignin8583 (const data: Pointer; MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME name='bPackSignin8583';
The function bUnpackSignin8583 (data: Pointer; Const MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME name='bUnpackSignin8583';
The function bPackSignout8583 (const data: Pointer; MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME name='bPackSignout8583';
End.

CodePudding user response:

Eldest brother you write code, cannot perform in Delphi 7, I changed your code, you see the right, under the consult, if the call this a few function, the structure, how to transmit the assignment in function?
 unit U8583; 

Interface

Const

DLLNAME='your DLL name;

Type
T8583=record
M_acTermCode: array [0.. 15] of char;
M_acTraceSerial: array [0.. 6] of char;
M_acAmount: an array of char [0.. 12];
M_acRespCode: array [0.. 3] of char;
19] m_acNonceStr: array [0.. of char;
M_acPrivate: an array of char [0.. 999];
M_acAddition: an array of char [0.. 999];
M_acDetail: an array of char [0.. 999];
end;

Implementation
The function bPackSignin8583 (const data: Pointer; MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME;
The function bUnpackSignin8583 (data: Pointer; Const MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME;
The function bPackSignout8583 (const data: Pointer; MSG: PAnsiChar; MsgLen: PInteger) : Boolean; Cdecl; External DLLNAME;
End.

CodePudding user response:

The function bPackSignin8583 (const data: t8583; MSG: PAnsiChar; Var msgLen: Integer) : Boolean; Cdecl; External DLLNAME;
The function bUnpackSignin8583 (var data: t8583; Const MSG: PAnsiChar; Var msgLen: Integer) : Boolean; Cdecl; External DLLNAME;
The function bPackSignout8583 (const data: t8583; MSG: PAnsiChar; Var msgLen: Integer) : Boolean; Cdecl; External DLLNAME;

CodePudding user response:

Greatly, this function call, how to pass parameters, can write a function call sample?

CodePudding user response:

 
//never actually run the test, you see line not line,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related