Use a specific DLL developed in C in a Delphi application

Posted on 2011-04-26
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 ?
Question by:LeTay
    LVL 32

    Accepted Solution


    Use Cardinal in delphi

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

    Expert Comment


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

    Author Comment

    The datatype was my first question
    I will now try using the DLL and may ask for additional stuff in the coming hours/days
    LVL 19

    Expert Comment

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

    Author Comment

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

    Author Comment

    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


    Author Comment

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

    Author Closing Comment

    Many thanks
    I did not realise that interfacing with external DLL written in C was so easy, finally !

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now