Link to home
Start Free TrialLog in
Avatar of LeTay
LeTay

asked on

Use a specific DLL developed in C in a Delphi application

I got a DLL developed by somebody else (see attachment) in C and I want to use it in my Delphi 2009 application
I specifically want to call the routine CalcDDTable
I think I have no (?) difficulty to define the routine in my application
Now this routine uses arrays
One passed as input and the other containing the result
The input one contains unsigned integers
Does that exists in Delphi ?
DLL-dds-21-k.pdf
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Do you still need more help with this or was it only the datatype mapping that you needed?
Avatar of LeTay
LeTay

ASKER

The datatype was my first question
I will now try using the DLL and may ask for additional stuff in the coming hours/days
Do you happen to have a .h file of the dll?
Avatar of LeTay

ASKER

Yes, I have everything but a .h file can't help in Delphi, can it ?
Avatar of LeTay

ASKER

Based on what I could understand from the documentation, I put the DDS.DLL in my executable directory and coded this in the Unit that uses it :
unit UDDS;

interface

function  CalcDDtable(ddTableDeal:array of Cardinal;var ddTableResults:array of integer):integer; stdcall; external 'DDS.DLL';
procedure DDSolver;

implementation

procedure DDSolver;
var
 ddTableDeal:array[1..16] of Cardinal;
 ddTableResults:array[1..20] of integer;
begin
 .../... work to fill in ddTableDeal array
 CalcDDtable(ddTableDeal,ddTableResults);
.../... work to get back results from ddTableResults
end;

Now I get a access violation in CalcDDtable execution on some address for read address some other address
Is the declaration of the function correct (stdcall, var for second argument) ?
And the real arguments passed ?

Thanks to help on this

Avatar of LeTay

ASKER

Hello, I found my error
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
Avatar of LeTay

ASKER

Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !