Skip to content
⌘ NSIS Forum Archive

InstallLib: counter for shared dll

2 posts

nvit#

InstallLib: counter for shared dll

Up today I use UpgradeDLL macro for installing shared dll.
For incrementing COUNTER of this dll I used addshareddll function:
!insertmacro UpgradeDLL ...
Push $SYSDIR\fbclient.dll
Call addshareddll
;--------------------------------
Function AddSharedDLL
   Exch $R1
   Push $R0
   ReadRegDword $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\SharedDLLs" $R1
   IntOp $R0 $R0 + 1
   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\SharedDLLs" $R1 $R0
   Pop $R0
   Pop $R1
   Sleep 100
 FunctionEnd
;--------------------------------- 
Today I decided to use InstallLib instead of UpgradeDLL.
I guessed, that InstallLib will increase COUNTER of shared dll itself and I don't need to use addshareddll function. But I can't understand how InstallLib increases COUNTER of shared dll if this dll already exists:
===============================================
IfFileExists "$SYSDIR\fbclient.dll" 0 InstallFBClient
 StrCpy $ALREADY_INSTALLED "1" ; 
InstallFBClient:
   !insertmacro InstallLib DLL $ALREADY_INSTALLED NOREBOOT_NOTPROTECTED "\INSTALL\fbclient.dll" "$SYSDIR\fbclient.dll" "$SYSDIR" 
But ALREADY_INSTALLED is always 1. Should I increase this var before calling macro? Or macro has to increase this var
itself?
nvit#
OK, now I've understood.
Macro InstallLib increases counter if ALREADY_INSTALLED is empty. All works.
Topic is closed.