Solved

Can't use a C++ (v7.1) and MFC DLL in Delphi 6.....

Posted on 2004-09-28
7
212 Views
Last Modified: 2006-11-17
I'm using Delphi 6 (Pascal) to load a C++/MFC DLL. In Delphi, after I load the library, I can see the entry points in the library. One of the functions in the library is TrackData. The entry point should be TrackData but it looks like this instead:

?TrackData@@YAHPAD@Z

I have never had a problem using a library in Delphi before. This DLL was written by another person in a sister company and I think that they need to do something to better expose the functions within their library but I'm not a C++ programmer so I wouldn't know what to tell them. It may not be a problem with their library or my loading of it. It may just be an incompatibility problem.

What I need is some kind of direction as to what they are not doing that needs to be done. Code examples or anything would be helpful. I know this isn't much to go on but ask me anything and I'll get back to you as soon as I can. If you have a question for the C++ programmer, give it to me and I'll relay it to them.

Extra Info: All parameters within the DLL functions are compatible with Delphi.

Thanks for any help given.


0
Comment
Question by:blueyellowgreen
  • 4
  • 3
7 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 500 total points
ID: 12169051
The function name has been mangled by the C++ compiler to indicate what type its arguments are. This mangling is usually incompatable from one compiler to the next.

You need to get the other c++ programmer to declare his functions using the

extern "C"

construct. This will remove the mangling, and you will be able to easily use it.

0
 

Author Comment

by:blueyellowgreen
ID: 12169206
Thanks for the quick reply. I've sent your comment to the c++ programmer. Fingers crossed! :)
0
 
LVL 14

Expert Comment

by:wayside
ID: 12169331
I think they could also fix this by adding the relevant functions to the library's .def file:

EXPORTS
  TrackData=?TrackData@@YAHPAD@Z

This might be easier than changing the code to use extern "C".
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:blueyellowgreen
ID: 12169466
I've sent her that comment also. :)
0
 

Author Comment

by:blueyellowgreen
ID: 12182970
Hi,

The C++ programmer is still working on the DLL changes. As soon as the suggestions given above have been tried, I will be back to accept one of the suggestions or ask for more suggestions.

Thanks for you patience.  :)

0
 

Author Comment

by:blueyellowgreen
ID: 12216812
Wayside, The extern "C" worked like a charm! Thanks very much!!! :)
0
 
LVL 14

Expert Comment

by:wayside
ID: 12217187
Glad I could help! :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

758 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