Skip to content
⌘ NSIS Forum Archive

Registering dll on reboot - dependency problems

7 posts

Bidger#

Registering dll on reboot - dependency problems

Hi folks. I'm using the UpgradeDLL macro to upgrade DLLs in
"$PROGRAMFILES\${COMPANY_NAME}\Shared\${PRODUCT_NAME}"

When the DLL needs to be upgraded, but is in use, this macro cunningly extracts the file to a temporary location and copies it over the actual location at reboot. In order to reregister the DLL, the macro also adds the following entry to the RunOnce registry key.

"C:\WINNT\SYSTEM32\rundll32.exe" "C:\Program Files\Company\Shared\Product\TheDll.dll",DllRegisterServer

Unfortunately, this does not work for me. This is because TheDll.dll has a static dependency (that I cannot change) on AnotherDll.dll that also resides in "$PROGRAMFILES\${COMPANY_NAME}\Shared\${PRODUCT_NAME}". Due to the way rundll32.exe uses LoadLibrary{1}, it does not search my installation directory for dependencies, and so fails to load TheDll.dll. This means TheDll.dll does not get reregistered and so the whole system doesn't work.

I have several choices[list=1][*]Bundle an appropriate version of regsvr32 with the installer and use this to do the RunOnce stuff instead of rundll32.[*]Stick with rundll32 and temporarily add my installation directory to the system path (will this then be used at the time RunOnce keys are executed?)[*]Find another, better, way to make the rundll32 trick work[/list=1]
Can anyone suggest a solution that works for Windows 9x onwards?

TIA - bidger


{1} See the MSDN info on LOAD_WITH_ALTERED_SEARCH_PATH and "the alternate file search strategy" that rundll32, unfortunately, does not use.
kichik#
A fast solution (assuming you wrote the DLL) would be setting the current directory in DllMain.
Bidger#
Thanks for the suggestion kichik but I think I've found a solution. Writing '"$SYSDIR\regsvr32.exe" /s "C:\Program Files\Company\Shared\Product\TheDll.dll"' to the RunOnce key seems to work fine. I had read somewhere that there can be problems with using regsvr32 like this - maybe one of the reasons NSIS has its own RegDll command? Is this method always going to work? Thanks again.
Bidger#
I see... Judging by MSDN KB239873, regsvr32.exe should be available on all Windows 95 systems that we target. Therefore I think we've got a solution. Many thanks.
Joost Verburg#
Nope, it is not available on the first edition of Windows 95. There is another page where you can download regsvr32.
Afrow UK#
Why not extract another nsis exe with no dialog, which is executed from RunOnce and contains the RegDLL bit onInit.

-Stu