Solved

Sharing DLL with Microsoft Visual C++

Posted on 1999-01-15
9
173 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

778 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