It's hard for me to call a function in a C ++ dll from delphi.
C ++ function is defined as follows
BALL_SCRUB_DLL_API int CALLING_CONVENTION bsl2_ModelBallFlight(float cam_X,
float cam_Y,
float cam_Z,
Ball3d* ball_data_in,
int n_balls_in,
Ball3d* ball_data_out,
int &n_balls_out);
The template structure is as follows:
typedef struct
{ float X;
float Y;
float Z;
float VX;
float VY;
float VZ;
int frame_id;
int flag;
} Ball3d;
I want to send the ball_data_in array from my delphi application, and the C ++ dll will return the same array type, but with the changed values to ball_data_out.
I defined the TBall3D entry as follows:
TBall3D = record
X : Single;
Y : Single;
Z : Single;
VX : Single;
VY : Single;
VZ : Single;
Framecount : Integer;
BallFlag : Integer;
end;
PBall3D = ^TBall3D;
TBall3DArray = array of TBall3D;
PBall3DArray = ^TBall3DArray;
The declaration of my function is as follows:
TBSL2_ModelBallFlight = function( const Cam_X, Cam_Y, Cam_Z : Single;
const ball_data_in : PBall3DArray;
const NFramesIn : Integer;
var ball_data_out : PBall3DArray;
const NFramesOut : Integer) : Integer; cdecl;
How do I make this call from delphi to dll? Any help would be greatly appreciated.
source
share