PDA

View Full Version : Load my DLL from InstallScript



Acomber
07-24-2002, 10:26 AM
Hello

I want to call a dll I wrote from InstallShield 7. The DLL is called AppWiz.dll and has a function ResetHKLM() which is passed no parameters but has an int return type.

This dll was written in Microsoft Visual Studio.

The .h file is:

#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT INT CALLBACK ResetHKLM();

I added AppWiz.dll to Setup files language independent.

In my InstallScript I use:

prototype cdecl AppWiz.ResetHKLM();

[Also tried prototype cdecl AppWiz.ResetHKLM(); which gave same error.]

My InstallShield code:

prototype cdecl AppWiz.ResetHKLM();

string szLicenseTool;
string szDLLName;
int ret;

begin
szDLLName = SUPPORTDIR^"AppWiz.dll";
ret = UseDLL(szDLLName);
ResetHKLM();
ret = UnUseDLL(szDLLName);

But on the ResetHKLM(); line get error:

Error 0x80040703

Failed to find dll function AppWiz.ResetHKLM

ret value is zero - ie OK. So I load the dll into memory OK.

What do I need to do to get this to work?

Angus Comber
angus@onlinesupport.co.uk

RobertDickau
07-24-2002, 11:57 AM
Maybe it's just me, but I've never got __declspec(dllexport) to work; instead, perhaps explicitly specify the exported function names using a DEF file, as in:

LIBRARY AppWiz

EXPORTS
ResetHKLM

Here's an old InstallShield newsletter article about writing DLLs for custom actions; it's intended for Basic MSI projects, but the general ideas still apply: http://www.installshield.com/news/newsletter/0108-articles/dlls-for-ipwi.asp.

Acomber
07-31-2002, 11:32 AM
Hello

That worked fine on ISWI v2 InstallShield. But when I did the same for Developer 7 I got error 1723 saying it could not find a dll. Presumably it could not find the dll in the custom action I created.

This is what I did in Developer 7:

1. In Setup/ Files/Billboards, Setup Files... Language Independent I inserted the dll called reset.dll.

2. In Sequences Actions I created the Custom Action in the same way as for ISWI v2.

3. I inserted this Custom Action in Sequences, Installation, User Interface. I put it in various locations but always got same error.

Any help would be much appreciated.

Why does it work OK in ISWI but not in Developer 7?

Angus Comber
angus@onlinesupport.co.uk

Acomber
08-01-2002, 07:06 AM
Hello

I tested on a different machine and it was the dll, NOT Developer 7 calling it which was the problem!

So problem solved.

Angus