Solved

Sharing DLL with Microsoft Visual C++

Posted on 1999-01-15
9
182 Views
Last Modified: 2010-05-18
Hi!! The problem I have is that, I have written a DLL in Delphi 3.0 and tested it work DLL calls in Delphi. But when I translate the codes to MS Visual C++, it give an error message and the programme halts.

Is there any ticks that I need to know to write an DLL for MS Visual C++?

Thanks!

regards,
James.
0
Comment
Question by:jhui
[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
9 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1356811
Use "cdecl" calling convention and don't use Delphi strings.

Instead of
 
  procedure test(str: string);

write

  procedure test(str: pchar); cdecl;

Please tell me if that helped...

Regards, Madshi.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1356812
Maybe some code from both DLLs would help...

from the Delphi DLL and the VC++ DLL....
0
 
LVL 3

Expert Comment

by:Ronald Buster
ID: 1356813
Any code would be appreciated, I'll made dozens of dll's in delphi and they are used by several programs written in entirely different programming languages.

regards,

Cono
0
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!

 

Author Comment

by:jhui
ID: 1356814
Hi!! I have added  "cdecl;" to all the export procedures, but the error stills happens.

What do you thinks? I have already make a simple VC++ programme to call my Delphi DLL, but it stills not working. Should I send you the code?

regards,
James.
0
 
LVL 3

Expert Comment

by:Ronald Buster
ID: 1356815
Send me the code and I will see what I can do for you !

regards,

Cono
0
 

Author Comment

by:jhui
ID: 1356816
Thanks Cono, Could you leave me your e-mail address to me. Or you can send to my account at "jameshui@geocities.com".

regards,
James.
0
 

Author Comment

by:jhui
ID: 1356817
Cono, Have you get the two files I sent to you? Do you have any suggestion for that?

Thanks!

regards,
James.
0
 

Author Comment

by:jhui
ID: 1356818
I have uploaded all the source code to my tripod's account,

The Delphi DLL source code is
http://members.tripod.com/~jameshui/990113.zip
The simple VC call DLL source code is
http://members.tripod.com/~jameshui/testdll.zip

regards,
James
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1356819
Make sure you calling convetions match:

eg:

In delphi write:

Procedure Fred(AnArg : Integer); cdecl; export;

in VC++ write

void __declspec(dllimport) Fred (int AnArg); // implicitly cdecl

or

void _cdecl fred(int AnArg); // or is it __cdecl? Damn underscores...

Cheers,

Raymond
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month3 days, 19 hours left to enroll

630 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