We help IT Professionals succeed at work.

Use a specific DLL developed in C in a Delphi application

LeTay
LeTay asked
on
310 Views
Last Modified: 2012-08-13
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
Comment
Watch Question

Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:

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

Author

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
MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
Do you happen to have a .h file of the dll?

Author

Commented:
Yes, I have everything but a .h file can't help in Delphi, can it ?

Author

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

Author

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

Author

Commented:
Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.