?
Solved

How to call C++Builder DLL in Delphi?

Posted on 2000-04-06
5
Medium Priority
?
533 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

770 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