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

Help with DLL creation


3 replies to this topic

Sacato

Sacato
  • Members
  • 4 posts

Posted 01 August 2003 - 09:47

Hi again,

I'm trying to create a dll to use as a custom action. I use the Installshield 3.5. The dll is created with borland c++ and the code is:

'************************************************************************************
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif

// Foo() function definition.
LONG WINAPI Foo(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szInst, LPSTR szDbase)
{ CHAR szTmp[1024];
int ret;

// Construct a string to display the values passed into Foo().
wsprintf(szTmp, "Extension called. hwnd=%x szSrcDir=%s szSupport=%s szInst=%s. Do you want" \
"to exit now?", hwnd, szSrcDir, szSupport, szInst);

// Display the string in a message box.
ret=MessageBox(hwnd, szTmp, "Test Extension", MB_YESNO);
if (ret==IDYES)
// Returning 0 causes the installation to end.
return(0);
else
// Returning non-zero causes the installation to continue.
return(1);
}

#ifdef __cplusplus
}
#endif
'************************************************************************************

I got the code from the Installshield help.

When I execute the setup, it get an error like "The function Foo is not exported".

Somebody can give me some code to export the function. I write something like that:

'************************************************************************************
__declspec(dllexport) LONG WINAPI Foo(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szInst, LPSTR szDbase);
'************************************************************************************

Then I have a def file that contains:

'************************************************************************************
LIBRARY Project2

EXPORTS
Foo
'************************************************************************************

It doesn't work. I don't know where I have to write the dexlspec(dllexport) function. It have to be write before the function, in the .h file, in the .cpp file?

Somebody can give me some code or help me with this?

Thanks

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 01 August 2003 - 11:16

Please look at your DLL with Dependency Walker to see if the name of the exported function has been mangled.

I don't use Borland C++, and I think your chances to get an answer to that are better if you post your question in a borland newsgroup.

Neo

Neo
  • Members
  • 48 posts

Posted 03 August 2003 - 02:39

Hi

I am not very sure about Borland C++, but try writing the function as

CODE

extern "C" __declspec(dllexport) LONG WINAPI Foo(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szInst, LPSTR szDbase)
{
 //Your Function body.

}


You can prototype this function in the .h file. But it is not mandatory. I've tried this with BloodShed Dev C++.

Regards

Neo.

luke_s

luke_s
  • Full Members
  • 532 posts

Posted 04 August 2003 - 07:36

Try this. I use this in Visual Studio

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
return TRUE;
}

>> Action.def File.
LIBRARY "msiAction"
EXPORTS
RunCommand


UINT __stdcall RunCommand(MSIHANDLE hInstall)
{
// custom action code
}