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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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?
ASKER
Yes, I have everything but a .h file can't help in Delphi, can it ?
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:ar ray 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,dd TableResul ts);
.../... 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
unit UDDS;
interface
function CalcDDtable(ddTableDeal:ar
procedure DDSolver;
implementation
procedure DDSolver;
var
ddTableDeal:array[1..16] of Cardinal;
ddTableResults:array[1..20
begin
.../... work to fill in ddTableDeal array
CalcDDtable(ddTableDeal,dd
.../... 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
ASKER
Hello, I found my error
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
ASKER
Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !
I did not realise that interfacing with external DLL written in C was so easy, finally !
Do you still need more help with this or was it only the datatype mapping that you needed?