Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Use a specific DLL developed in C in a Delphi application

Posted on 2011-04-26
8
Medium Priority
?
301 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
0
Comment
Question by:LeTay
  • 5
  • 2
8 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35467811

Use Cardinal in delphi

Unsigned simply means the datat type does not support values less than zero
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35468594

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

Author Comment

by:LeTay
ID: 35468737
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 19

Expert Comment

by:MerijnB
ID: 35473112
Do you happen to have a .h file of the dll?
0
 

Author Comment

by:LeTay
ID: 35481923
Yes, I have everything but a .h file can't help in Delphi, can it ?
0
 

Author Comment

by:LeTay
ID: 35482851
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
 

Author Comment

by:LeTay
ID: 35484266
Hello, I found my error
I did not declare argument via a structure (TRec)
Now I did and it works perfectly well
0
 

Author Closing Comment

by:LeTay
ID: 35484276
Many thanks
I did not realise that interfacing with external DLL written in C was so easy, finally !
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question