Solved

How to call C++Builder DLL in Delphi?

Posted on 2000-04-06
5
516 Views
Last Modified: 2010-04-04
I've created a DLL that came from C++Builder code using the 'extern "C" __declspec(dllexport)' modifier to export the functions I want to be able to call.  It compiles okay and then when I try to run a test program in Delphi to call the functions, I get an "Entry Point Not Found" error.  More specifically it says "The procedure entry point <function name> could not be located in the dynamic link library <dll filename>".

I looked over my C++ code and I've seemed to have done everything right.  The only clue I have is from a Delphi book that tells me that I need to "translate the C++ import library to a Pascal equivalent inteface unit".  Am I on the right track?
0
Comment
Question by:uhoang
5 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 2691450
You can make a unit like this:

unit DLLinterface;

interface

Procedure Fred(Arg : Integer);

implementation

Procedure Fred(Arg : Integer); external 'MyDLL.DLL' name 'Fred';

end.

This will automatically load the DLL (if it can find it!) and allow you to call procedure fred defined in it.

It sounds like you might have the case of the function name wrong - be sure it matches!

Cheers,

Raymond.
0
 

Author Comment

by:uhoang
ID: 2691498
Ok, I did that and I still get the same result.  Is it possible that there's something wrong in the DLL?  After I build the DLL in C++Builder and place it in a folder in a correct path, do I need to do anything else like register it or anything?
0
 

Expert Comment

by:FMJMEE
ID: 2691505
See the web page
http://www.drbob42.com/delphi/headconv.htm
hope it helps
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2691517
Can you post the declaration of the function in the DLL and in the import unit?

Cheers,

Raymond.
0
 
LVL 2

Expert Comment

by:Felixin
ID: 2692445
Hi,

Rwilson is OK.


You have to make sure that the protocol to call the DLL is correct.

Search i Delphi help for:

Calling conventions

There you will see that a DLL can have different calling methods, like (extracted)

The table below summarizes calling conventions.

Directive      Parameter order      Clean-up      Passes parameters in registers?
register      Left-to-right      Routine      Yes
pascal      Left-to-right      Routine      No
cdecl      Right-to-left      Caller      No
stdcall      Right-to-left      Routine      No
safecall      Right-to-left      Routine      No

Take the correct one a put it in the header of the function like this

function MyFunction : MyResult; cdecl; external 'MyDLL.DLL' name 'MyFunction';

Best regards
0

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

18 Experts available now in Live!

Get 1:1 Help Now