Calling a callback function in Delphi from a C++ DLL
I am sitting with a similar error however my C++ declarations is a little bit different.
typedef int __stdcall CALLBACK(void* pP1, int I1, unsigned char* pUC,
int I2, int I3, int I4, void* pP2);
which I converted to:
type TCALLBACK = function(var pP1: Pointer; var I1: integer;
var pUC: PChar; var I2: Integer; var I3: Integer; var I4: Integer;
var pP2: Pointer): Integer cdecl stdcall;
Function referencing the callback fucntion:
int MyFunction(void* pP1, TCALLBACK* pCallback, void* pP2);
which I converted to:
MyFunction: function(pP1: Pointer; var pCallBack: Pointer;
pP2: Pointer): Integer cdecl stdcall;
Calling the function:
var P : Pointer;
begin
//Addr
P := Addr(PCALLBACK); //had this as @PCALLBACK
UFS_StartCapturing(ScannerHandle, P, self);
end;
Callback function declared in Delphi as:
function MyCallback(var pP1: Pointer; var I1: integer; var pUC: PChar;
var I2: Integer; var I3: Integer; var I4: Integer;
var pP2: Pointer): Integer;
var
MainForm : TfrmMain;
begin
//Do your thing
end;
I know my problem lies with the Pointer to the callback (CALLBACK*), and am now trying:
ADRESSOFCALLBACK= ^TCALLBACK;
MyFunction: function(pP1: Pointer; var pCallBack: ADRESSOFCALLBACK;
pP2: Pointer): Integer cdecl stdcall;
Still not working.