MFC DLL ok in Call DLL function?

Got a problem you cannot solve? Try here.
Fig
Posts: 22
Joined: Tue Aug 15, 2006 12:27 pm

MFC DLL ok in Call DLL function?

Postby Fig » Mon Aug 21, 2006 1:33 pm

Can I use an MFC dll (dynamically linked to MFC80.dll) in the Call DLL function of my script?

I am calling wbkey32.dll but always get FUNCTIONNOTFOUND returned. I have checked the exports of my .dll and the called function exists there. I have checked and re-checked the syntax and spelling within my IA script.

I also use this .dll within my deployed MFC app.

In pseudo-code:

Code: Select all

CWbKey32App theApp;
// ... a bunch of MFC stuff, like MESSAGE_MAP, etc., left out here for brevity.

BOOL CWBKey32App::InstallKey2(
   long lVal1,   // input
   long lVerMajor,   // major version number
   long lVerMinor)   // minor version number
{
   // do some stuff...

   return TRUE;
}

extern "C" long WBInstallKey2(
   long lVal1,   // input
   long lVerMajor,   // major version number
   long lVerMinor)   // minor version number
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   BOOL bReturn = theApp.InstallKey2(lVal1, lVerMajor, lVerMinor);

   return ((bReturn) ? 0L : 1L); // return 0 on success
}

In the .def file
; WBKey32.def : Declares the module parameters for the DLL.

LIBRARY      "WBKey32"
EXPORTS
   WBInstallKey2 @1


Any help pointing me in the right direction would be appreciated.
... Fig

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Mon Aug 21, 2006 3:43 pm

There might be name mangling involved. Please make sure you export your functions using this form (or similar):

Code: Select all

extern "C" {

   __declspec(dllexport) int WINAPI
                FunctionName([parameters]);

}
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

Fig
Posts: 22
Joined: Tue Aug 15, 2006 12:27 pm

Postby Fig » Mon Aug 21, 2006 4:40 pm

Thanks for the reply...

WINAPI is just short for _stdcall

I have already wrapped my exported function in 'extern "C"' specifically to prevent name mangling. Additionally, when I checked the exported symbols the function was named as I expected it to be (not mangled).

I did not pre-pend a _declspec identifier, but I *did* use a .def file and the function name is exported.

I suspect there is some name decoration that has gone awry, but as far as you know there are no MFC-specific limitations, right?
... Fig

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Mon Aug 21, 2006 4:51 pm

Yes, AFAIK there are no MFC limitations - as long as name mangling, calling conventions aren't an issue...
Michael Nesmith

InstallAware

Home of The Next Generation MSI Installer

Get your free copy today - http://www.installaware.com/


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 170 guests