Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Calling Visual C++ DLL functions from ISD


3 replies to this topic

wernerf

wernerf
  • Members
  • 22 posts

Posted 19 September 2002 - 17:08

Hi all.

I'm trying to call functions from a DLL I created with Visual C++ 6.0 from within ISD 7.

When I declare the DLL function this way:

 extern "C"
  stdcall funcname(
       LPCSTR, LPCSTR, LPSTR))

the DLL exports a function named "_funcname@12", a mangled name I cannot use in the "prototype" statement of ISD (I receive errors when trying to). To find out the exported function names, I used DUMPBIN /exports. There's no .DEF file in the VC project.

Then I changed "stdcall" to "cdecl"; after that, the function export was named "funcname", though VC documentation made me expect an export name of "_funcname" (there's a chapter in the online books describing name mangling under the different calling standards) ! In the ISD 7 prototype, I also added the "cdecl" keyword.

How does all this work together?

Question 1) How can I use C-functions declared extern "C" stdcall in a VC 6-DLL from within ISD 7 using "prototype"s?

Question 2) Why is the exported name of the extern "C" cdecl function "funcname" and not "_funcname"? (I know, this is rather a VC- than an ISD problem)

TIA.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 September 2002 - 07:04

I suggest you use a .def file in your VC project

wernerf

wernerf
  • Members
  • 22 posts

Posted 20 September 2002 - 10:22

I tried with and without an .DEF file, but currently functions are exported using __declspec(dllexport). Then, in my experience an 'extern "C" stdcall funcname(...)' function will be decorated and exported as _funcname@99.

By the way, by studying many newgroup postings about related issues, I never saw an example using 'stdcall'; in most cases, the function definition on the C++ side was neither using cdecl nor stdcall, thus implicitly using 'cdecl' (I think).

So, again this leads to the problem how to utilize decorated export names from within IS, especially when they include the '@' char. Might it help to use a .def file with a special EXPORT syntax? I tried to use sort of 'alias' names using

 EXPORTS funcname=_funcname@99 @1

but received build errors when doing so (again, the linker did not seem to like the '@' in the decorated name).

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 20 September 2002 - 10:32

You can call Windows APIs and I believe they use stdcall, so this should work (with unmangled function names)
A sample DLL with .def file can be found at
http://www.installsi...en/isp_misc.htm
in section "Setup Extension DLL"