Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Sharing DLL with Microsoft Visual C++

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
jhui
Asked:
jhui
1 Solution
 
MadshiCommented:
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
 
viktornetCommented:
Maybe some code from both DLLs would help...

from the Delphi DLL and the VC++ DLL....
0
 
Ronald BusterCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jhuiAuthor Commented:
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
 
Ronald BusterCommented:
Send me the code and I will see what I can do for you !

regards,

Cono
0
 
jhuiAuthor Commented:
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
 
jhuiAuthor Commented:
Cono, Have you get the two files I sent to you? Do you have any suggestion for that?

Thanks!

regards,
James.
0
 
jhuiAuthor Commented:
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
 
rwilson032697Commented:
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

Technology Partners: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now