Dlls in VC++ and BCB

S

Seabass

Hey all,
I have come across the following issue. I have an application written
with Borland C++ Builder, this application loads dlls(plug-ins)
dynamically during run time. To make things easier for my users, I am
trying to make it possible for them to create dlls in C++ Builder
(which works great) and VC++. I tried to use the same code in VC++
builder, which compilled fine, but during runtime I came across a
problem. First of all, this is how I load my DLLS in the host app:

LibAddress = LoadLibrary("C:\\Development\\VC++
DLL\\Release\\DLL.dll");
Connect = (TConnect) GetProcAddress(mydll->LibAddress,"_Connect);
//trying to get a function from the dll
now, in my DLL I export the function Connect the following way in
both dlls:
#define DLL_MODE __declspec(dllexport)
extern "C" void DLL_MODE Connect(TUser*User);
now, this works fine with the BCB dll, but loading the function with
GetProcAddress from the VC++ returned NULL. Using Dumpbin on the DLL
showed that the function was exported as Connect not as _Connect.
Changing the function to look for Connect instead of _Connect worked,
but why is this? Is there a way to get VC++ to report the name
correctly?

thank you

Seabass
 
M

Mike Wahler

Seabass said:
Hey all,
I have come across the following issue. I have an application written
with Borland C++ Builder, this application loads dlls(plug-ins)
dynamically during run time. To make things easier for my users, I am
trying to make it possible for them to create dlls in C++ Builder
(which works great) and VC++. I tried to use the same code in VC++
builder, which compilled fine, but during runtime I came across a
problem. First of all, this is how I load my DLLS in the host app:

Please see:

http://www.slack.net/~shiva/welcome.txt

which will inform you that none of 'Borland C++ Builder',
'DLL' or 'VC++' are topical here. Only the ISO standard
C++ language is.

There are already newsgroups for those two compilers,
and for Windows programming issues, where people who
are very knowledgable about such things are just
waiting to help you with these issues.

See www.groups.google.com and/or www.usenet.org
to find which groups are for which topics.

Also the Borland and Microsoft web sites
( www.borland.com ), ( www.microsoft.com )have
links to groups about their products and technologies.

Good luck.

-Mike
 
S

shakahshakah

Why do you expect the symbol to be exported as "_Connect"?

After an admittedly cursory glance at your code, I'd expect the symbol to be
exported as "Connect" (as you report VC++ does).
 
S

Seabass

Ah okay,
I was just used to BCB exporting it using the standard C calling
convention (with that extra underscore). A friend of mine pointed out
that this doesn't apply to VC++ and that I should make sure it uses
the Standard Call Convention __stdcall. =)


thank you for your reply
 
M

Mike Wahler

Seabass said:
Ah okay,
I was just used to BCB exporting it using the standard C calling
convention
Standard C does not have a 'calling convention'.
(with that extra underscore). A friend of mine pointed out
that this doesn't apply to VC++ and that I should make sure it uses
the Standard Call Convention __stdcall. =)

Standard C has nothing called '__stdcall', without or without
the underscores.

'stdcall' is a Microsoft invention.


-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top