Solved

Sharing DLL with Microsoft Visual C++

Posted on 1999-01-15
9
172 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
 

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
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.

 
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

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

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

13 Experts available now in Live!

Get 1:1 Help Now