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
LVL 1
LeTayAsked:
Who is Participating?
 
Ephraim WangoyaCommented:

Use Cardinal in delphi

Unsigned simply means the datat type does not support values less than zero
0
 
Ephraim WangoyaCommented:

Do you still need more help with this or was it only the datatype mapping that you needed?
0
 
LeTayAuthor Commented:
The datatype was my first question
I will now try using the DLL and may ask for additional stuff in the coming hours/days
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
MerijnBSr. Software EngineerCommented:
Do you happen to have a .h file of the dll?
0
 
LeTayAuthor Commented:
Yes, I have everything but a .h file can't help in Delphi, can it ?
0
 
LeTayAuthor Commented:
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

0
 
LeTayAuthor Commented:
Hello, I found my error
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
0
 
LeTayAuthor Commented:
Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.