dlldependenciesinstallshieldinstallscript

InstallShield UseDLL() doesn't find dll dependencies in the same directory


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


Solution

  • 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.)