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 dll in installscript


8 replies to this topic

bluesky9898

bluesky9898
  • Members
  • 11 posts

Posted 15 January 2004 - 17:41

I plan to write a installscript in which I call a dll inside the package. In my understanding, I need to do:
1. add key into Binary Table;
2. modify CustomAction table;
3. useDll(dllName) in script.

But I couldn't make it work. Can someone give me a little detailed explanation?

Thanks,

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 15 January 2004 - 18:24

In addition you will need to write script code that extracts the file form the binary table.
You have two simpler alternatives:
a) put the file in the Support Files section fo the IDE instead of the binary table. InstallShield will then extract it for you.
b) Don't use InstallScript but create a custom action that calls a dll, stored in the binary table. This is the simplest way if all you need to do is call the DLL. If you need extra code around your DLL call, you should use option a)

bluesky9898

bluesky9898
  • Members
  • 11 posts

Posted 15 January 2004 - 18:44

Stefan,

Thanks. I added dll to support file, in the script file:
#define DLL_FILE "testDll.dll"

prototype testDll.fnTestDll();
....
UseDLL (SUPPORTDIR^DLL_FILE);
n1 = fnTestDll();
UnUseDLL (SUPPORTDIR^DLL_FILE);

Dll code is: (Miscrofot Visual Studio C++ 6. Calling Convention is __stdcall)
TESTDLL_API int fnTestDll(void)
{
return 42;
}

I can see the loading of dll is successful. However, the function call fails.

What did I do wrong?

Thanks again.

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 January 2004 - 19:24

CODE

#define DLL_FILE "testDll.dll"
NUMBER n1;
NUMBER nResult;
...
prototype NUMBER testDll.fnTestDll();
....
nResult = UseDLL (SUPPORTDIR^DLL_FILE);
n1 = testDll.fnTestDll();
nResult = UnUseDLL(SUPPORTDIR^DLL_FILE);

Edited by Glytzhkof, 15 January 2004 - 19:25.

Regards
-Stein Åsmul

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 January 2004 - 19:26

You say the calling convention is __stdcall. If things still don't work, try to specify cdecl instead:
CODE

prototype cdecl NUMBER testDll.fnTestDll();

Regards
-Stein Åsmul

bluesky9898

bluesky9898
  • Members
  • 11 posts

Posted 15 January 2004 - 21:26

I tried both and neither of them worked. Is there any other setting I need to consider? Does this mean I can't use MS Visual C++ dll project?

Do you have a small working example project which can be shared?

Thanks,



Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 January 2004 - 22:22

I will see if I can dig up a test project. In the mean time I would try your script without using the DECLARE section. Just hard code the dll name in the script (just to verify).
Regards
-Stein Åsmul

bluesky9898

bluesky9898
  • Members
  • 11 posts

Posted 15 January 2004 - 23:43

Glytzhkof,

Finally it worked. I need to put extern "c" to avoid function name mangled.

Thanks for your patience. tongue.gif biggrin.gif

Glytzhkof

Glytzhkof
  • Moderators
  • 1,447 posts

Posted 15 January 2004 - 23:50

Ah, yeah. It might also work to add a *.def file to your project. See this article: http://www.installsh...ls-for-ipwi.asp

Edited by Glytzhkof, 15 January 2004 - 23:51.

Regards
-Stein Åsmul