0

I have 1 dll file which I try to load during the installation with UseDLL() in one of my installscripts. this dll has 2 dlls it depends on. they both located on the same directory of the main dll.

When in build the installation with an older installshield - it find it's dependencies and works fine. When I try to build it with IS2016, it fails because it doesn't find it's dependencies. (If I put these 2 dlls in SysWOW64 - it finds them and works fine).

What is the problem?

Thanks, Dudi

DudiD
  • 215
  • 2
  • 7
  • 16

1 Answers1

2

It looks like InstallShield 2018 makes this easier through a new Enable/Disable flag called DLL_DIRECTORY_SUPPORTDIR. But in InstallShield 2016 there's a good chance you can add the following InstallScript code to find dependencies in SUPPORTDIR. If your DLLs are in a different directory, substitute that instead.

// Add prototype for SetDllDirectory(); this typically goes near the top of your script
prototype number kernel32.SetDllDirectoryW(wstring);
// Call it; this goes in a function called before your UseDLL call
SetDllDirectoryW(SUPPORTDIR);

Note that doing this removes some protection against DLL planting, so it is safest to do this only if you ensure the DLLs in question are either proactively resistant to such things, or if you vet and secure the directory in question. (I'm uncertain whether InstallShield does this for you.)

Michael Urman
  • 15,737
  • 2
  • 28
  • 44
  • Thanks, it works! Although I don't understand why this is happens in IS2016 as they mentioned the change was done in IS2018. – DudiD Mar 18 '19 at 10:40
  • Does "SetDllDirectoryW" as an opposite function? so I can remove SUPPORTDIR from dll search path when I done installation? thanks! – DudiD Mar 18 '19 at 10:41
  • To clarify, the Enable/Disable option was added in 2018; the protections were added in 2016 and are available as hot fixes to earlier versions. Microsoft's documentation for [SetDllDirectoryW](https://learn.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setdlldirectoryw) explains how to reverse things, but I don't recall whether you can control passing NULL vs empty-string in InstallScript. – Michael Urman Mar 22 '19 at 01:31