This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Using a .dll
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 24, 2013
01:01 PM
Using a .dll
I am currently using InstallShield 2013 and Visual Studio 2010. I have been attempting to create a .dll file for use with installShield. I am able to load and unload my .dll, but when I try to call the method from the dll, the installer ends abruplty. I have read multiple forums and cannot find a solution. I will post my code below:
InstallScript:
#include "ifx.h"
#define My_dll "c:\\users\\...\\documents\\visual studio 2010\\Projects\\HelloWorld\\Debug\\HelloWorld.dll"
prototype cdecl HelloWorld.Hello();
export prototype MyFunction(HWND);
///////////////////////////////////////////////////////////////////////////////
//
// Function: MyFunction
//
// Purpose: This function will be called by the script engine when
// Windows(TM) Installer executes your custom action (see the "To
// Do," above).
//
///////////////////////////////////////////////////////////////////////////////
function MyFunction(hMSI)
NUMBER nResult;
begin
nResult = UseDLL (My_dll);
if (nResult = 0) then
MessageBox ("UseDLL successful \n\n.DLL file loaded.", INFORMATION);
else
MessageBox ("UseDLL failed.\n\nCouldn't load .DLL file.", SEVERE);
endif;
Hello(); <-----------------------------------------------------------------------DLL function call
if (UnUseDLL (My_dll) < 0) then
MessageBox ("UnUseDLL failed.\n\nDLL still in memory.", SEVERE);
else
MessageBox ("UnUseDLL successful.\n\n.DLL file removed from memory.", INFORMATION);
endif;
end;
Incase you can help debug my C++, Here is what I modified:
stdafx.h:
// TODO: reference additional headers your program requires here
#include "HelloWorld.h"
HelloWorld.h:
#ifndef HELLOWORLD_H
#define HELLOWORLD_H
__declspec(dllexport) void Hello(void);
#endif
HelloWorld.cpp:
#include "stdafx.h"
#include "HelloWorld.h"
void Hello()
{
MessageBox( NULL, TEXT("Hello World"),
TEXT("In a DLL"), MB_OK);
}
I appreciate the help.
InstallScript:
#include "ifx.h"
#define My_dll "c:\\users\\...\\documents\\visual studio 2010\\Projects\\HelloWorld\\Debug\\HelloWorld.dll"
prototype cdecl HelloWorld.Hello();
export prototype MyFunction(HWND);
///////////////////////////////////////////////////////////////////////////////
//
// Function: MyFunction
//
// Purpose: This function will be called by the script engine when
// Windows(TM) Installer executes your custom action (see the "To
// Do," above).
//
///////////////////////////////////////////////////////////////////////////////
function MyFunction(hMSI)
NUMBER nResult;
begin
nResult = UseDLL (My_dll);
if (nResult = 0) then
MessageBox ("UseDLL successful \n\n.DLL file loaded.", INFORMATION);
else
MessageBox ("UseDLL failed.\n\nCouldn't load .DLL file.", SEVERE);
endif;
Hello(); <-----------------------------------------------------------------------DLL function call
if (UnUseDLL (My_dll) < 0) then
MessageBox ("UnUseDLL failed.\n\nDLL still in memory.", SEVERE);
else
MessageBox ("UnUseDLL successful.\n\n.DLL file removed from memory.", INFORMATION);
endif;
end;
Incase you can help debug my C++, Here is what I modified:
stdafx.h:
// TODO: reference additional headers your program requires here
#include "HelloWorld.h"
HelloWorld.h:
#ifndef HELLOWORLD_H
#define HELLOWORLD_H
__declspec(dllexport) void Hello(void);
#endif
HelloWorld.cpp:
#include "stdafx.h"
#include "HelloWorld.h"
void Hello()
{
MessageBox( NULL, TEXT("Hello World"),
TEXT("In a DLL"), MB_OK);
}
I appreciate the help.
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 24, 2013
05:06 PM
If you have a copy of Dependency Walker or the dumpbin tool that ships with Visual Studio, is the "Hello" function exported? For example, if you run dumpbin /exports HelloWorld.dll, does Hello show up?
If not, you might try adding a .def file to your VS project: add a text file called HelloWorld.def, with contents:
If not, you might try adding a .def file to your VS project: add a text file called HelloWorld.def, with contents:
LIBRARY "HelloWorld"
EXPORTS
Hello
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 24, 2013
05:09 PM
Also, is this an InstallScript project or a Windows Installer project? If it's MSI, you might try creating a DLL you can call directly as a custom action, rather than doing it in two steps.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 28, 2013
06:25 AM
The project I am using is a Basic MSI project, I tried to use the UseDLL() method and also tried to create a custom action for the dll. In creating a custom action, the method doesn't show up in the method browser when I click on the ellipse. I also tried depenpancy walker and the function signature does show up.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 28, 2013
07:36 AM
The InstallShield help topic "Calling Functions in Windows Installer DLL Files" has a short walkthrough that might be useful. It has an example of the function signature that a DLL you call directly from a custom action wants.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 28, 2013
08:02 AM
I read this tutorial http://www.ni.com/white-paper/3056/en/#toc1 which showed how to go into the project properties and set the linker to look for the .def file that you suggested I create and I got it to work. Thanks so much for your help.