• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • 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 BusterOwnerCommented:
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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
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 BusterOwnerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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