NSIS 2.01 features a new system for the installation and uninstallation of dynamic link libraries (DLL) and type libraries (TLB). Using this new system you can handle the complete setup with one single line of code:
The macros are stored in the header file Library.nsh, which should be included in scripts using this system:
!include Library.nsh
Note that you can only compile scripts using this system on Windows systems. It is not possible to compile on Linux etc.
The InstallLib macro allows you to install a library.
To ask the user for a reboot if required, use the Modern UI with a Finish page or use IfRebootFlag and make your own page or message box.
libtype shared install localfile destfile tempbasedir
libtype
The type of the library
DLL - Dynamic link library (DLL)
REGDLL - DLL that has to be registered
TLB - Type library or DLL that contains a type LIBRARY
REGDLLTLB - DLL that has to be registered and contains a type library
shared
Specify whether the library is shared with other applications
NOTSHARED - The library is not shared
$VARNAME - Variable that is empty when the application is installed for the first time, which is when the shared library count will be increased.
install
Specify the installation method
REBOOT_PROTECTED
NOREBOOT_PROTECTED
REBOOT_NOTPROTECTED
NOREBOOT_NOTPROTECTED
localfile
Location of the library on the compiler system
destfile
Location to store the library on the user's system
tempbasedir
Directory on the user's system to store a temporary file when the system has to be rebooted.
For Windows 9x/ME support, this directory should be on the same volume as the destination file (destfile). The Windows temp directory could be located on any volume, so you cannot use this directory.
LIBRARY_SHELL_EXTENSION
LIBRARY_COM
;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is ;already installed. For example: IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;Replace MyApp.exe with your application filename StrCpy $ALREADY_INSTALLED 1 new_installation: !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED dllname.dll $SYSDIR\dllname.dll $SYSDIR
The UnInstallLib macro allows you to uninstall a library.
libtype shared uninstall file
libtype
The type of the library
DLL - Dynamic link library (DLL)
REGDLL - DLL that has to be registered
TLB - Type library or DLL that contains a type LIBRARY
REGDLLTLB - DLL that has to be registered and contains a type library
shared
Specify whether the library is shared with other applications
NOTSHARED - The library is not shared
SHARED - The library is shared and should be removed if the shared library count indicates that the file is not in use anymore..
uninstall
Specify the uninstallation method
NOREMOVE
REBOOT_PROTECTED
NOREBOOT_PROTECTED
REBOOT_NOTPROTECTED
NOREBOOT_NOTPROTECTED
file
Location of the library
LIBRARY_SHELL_EXTENSION
LIBRARY_COM
!insertmacro UnInstallLib REGDLL SHARED REBOOT_NOTPROTECTED $SYSDIR\dllname.dll
Add this code to your script to install and uninstall the VB6 runtimes.
The correct version of the following files should be stored in your script folder (or modify the paths to the local files if you want to use another folder):
A Microsoft article that explains how to obtain these files is available.
To ask the user for a reboot if required, use the Modern UI with a Finish page or use IfRebootFlag and make your own page or message box.
!include Library.nsh Var ALREADY_INSTALLED Section "-Install VB6 runtimes" ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if the application is already installed. For example: IfFileExists "$INSTDIR\MyApp.exe" 0 new_installation ;Replace MyApp.exe with your application filename StrCpy $ALREADY_INSTALLED 1 new_installation: !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR" !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED "comcat.dll" "$SYSDIR\comcat.dll" "$SYSDIR" !insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_PROTECTED "asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR" !insertmacro InstallLib TLB $ALREADY_INSTALLED REBOOT_PROTECTED "stdole2.tlb" "$SYSDIR\stdole2.tlb" "$SYSDIR" SectionEnd Section "-un.Uninstall VB6 runtimes" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll" !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat32.dll" !insertmacro UnInstallLib DLL SHARED NOREMOVE "$SYSDIR\asycfilt.dll" !insertmacro UnInstallLib TLB SHARED NOREMOVE "$SYSDIR\stdole2.tlb" SectionEnd
You can use similar code to install common VB6 ActiveX controls (such as the controls for Windows Common Controls).