Solved

How to call C++Builder DLL in Delphi?

Posted on 2000-04-06
5
520 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

17 Experts available now in Live!

Get 1:1 Help Now