Home > Back-end >  C defined function call DLL call into Delphi
C defined function call DLL call into Delphi

Time:10-19

A DLL file name called cesi. DLL
Some of the C functions are defined as follows:
# ifdef ID_FPRCAP_EXPORTS
# define ID_FPRCAP_API __declspec (dllexport)
# the else
# define ID_FPRCAP_API __declspec (dllimport)
# endif


1, ID_FPRCAP_API int __stdcall LIVESCAN_GetBright (int nChannel, int * pnBright);

2, ID_FPRCAP_API int __stdcall LIVESCAN_GetFPRawData (int nChannel, unsigned char * pRawData);

3, ID_FPRCAP_API int __stdcall LIVESCAN_GetDesc (char pszDesc [1024]).

4, ID_FPRCAP_API int __stdcall LIVESCAN_SetBufferEmpty (unsigned char * pImageData, long imageLength);

How to put them into the Delphi of function calls, and 1, for example, my Delphi is:
The function LIVESCAN_GetBright (nChannel: integer; PnBright: pInteger) : integer; Stdcall; External 'cesi. DLL' name 'LIVESCAN_GetBright';

His call
Procedure TForm1. Button9Click (Sender: TObject);
Var
Lddbd1, TDH: integer;
Ld: PInteger;
The begin
TDH:=1;
Lddbd1:=LIVESCAN_GetBright (TDH, ld);//lddbd1 to 1 function call is successful, otherwise failure
Memo2. Text:=inttostr (integer (DBD ^));
end;
So always call fails,
Who can help me define the above four words of C functions into Delphi and a button control form under the call (the return value of 1 is successful, otherwise failure)

Thank you for the first

CodePudding user response:

The function LIVESCAN_GetBright (nChannel: Integer; PnBright: pInteger {var nBright available here: an Integer, it is necessary to test ^_^}) : Integer; Stdcall; External 'cesi. DLL';
The function LIVESCAN_GetFPRawData (nChannel: Integer; PRawData: PByte) : Integer; Stdcall; External 'cesi. DLL';
The function LIVESCAN_GetDesc (pszDesc: PAnsiChar) : Integer; Stdcall; External 'cesi. DLL';
The function LIVESCAN_SetBufferEmpty (pImageData: PByte; ImageLength: LONG) : Integer; Stdcall; External 'cesi. DLL';

Procedure TForm1. Button9Click (Sender: TObject);
Var
NResult: Integer;
NBright nChannel: Integer;
The begin
NChannel:=1;
NBright:=0;
NResult:=LIVESCAN_GetBright (nChannel, @ nBright);//if the stated as var nBright: Integer, here don't need to take @ address
Memo2. Text:='Result=' + IntToStr (nResult) + '- & gt; '+' nBright='+ inttostr (nBright);
end;

CodePudding user response:

Procedure TForm1. Button9Click (Sender: TObject);
Var
SzDesc: array [0.. 1024-1] of AnsiChar;
NResult: Integer;
The begin
NResult:=LIVESCAN_GetDesc (@ szDesc [0]).
end;

CodePudding user response:

Stdcall - & gt; cdecl

CodePudding user response:

Extern "C"
{

.
}

CodePudding user response:

Check the name of DLL function method