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

Use Cardinal in delphi

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

Do you still need more help with this or was it only the datatype mapping that you needed?
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
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?
LeTayAuthor Commented:
Yes, I have everything but a .h file can't help in Delphi, can it ?
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;


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


procedure DDSolver;
 ddTableDeal:array[1..16] of Cardinal;
 ddTableResults:array[1..20] of integer;
 .../... work to fill in ddTableDeal array
.../... work to get back results from ddTableResults

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

LeTayAuthor Commented:
Hello, I found my error
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
LeTayAuthor Commented:
Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !
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.