Sorry if my question sounds stupid but I am relatively a newbie and I can't explain something strange going on in my code.
Remember the original PageReinstall in the makensis.nsi example?
PHP Code:
Function PageReinstall
ReadRegStr $R0 HKLM "${D_INSTALLKEY}" ""
${If} $R0 == ""
Abort
${EndIf}
ReadRegDWORD $R0 HKLM "${D_INSTALLKEY}" "VersionMajor"
ReadRegDWORD $R1 HKLM "${D_INSTALLKEY}" "VersionMinor"
ReadRegDWORD $R2 HKLM "${D_INSTALLKEY}" "VersionRevision"
ReadRegDWORD $R3 HKLM "${D_INSTALLKEY}" "VersionBuild"
StrCpy $R0 $R0.$R1.$R2.$R3
${VersionCompare} ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} $R0 $R0
${If} $R0 == 0
StrCpy $R1 "${D_PRODUCT} ${VERSION} is already installed. Select the operation you want to perform and click Next to continue."
StrCpy $R2 "Add/Reinstall components"
StrCpy $R3 "Uninstall ${D_PRODUCT}"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
StrCpy $R0 "2"
${ElseIf} $R0 == 1
StrCpy $R1 "An older version of ${D_PRODUCT} is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
StrCpy $R2 "Uninstall before installing"
StrCpy $R3 "Do not uninstall"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${D_PRODUCT}."
StrCpy $R0 "1"
${ElseIf} $R0 == 2
...
Well, when I implemented my first release, I neglected to to implement the version numbers in the registry. So now when I release a new installer with better code, I want it to be able to detect its presence and call it. Fortunately, both the older version and the new one have the uninstaller information in the same place in the registry ($D_UNINSTALLKEY).
So I modified the above to:
PHP Code:
Function PageReinstall
ReadRegStr $R0 HKLM "${D_INSTALLKEY}" ""
${If} $R0 == ""
Abort
${EndIf}
ReadRegDWORD $R0 HKLM "${D_INSTALLKEY}" "VersionMajor"
ReadRegDWORD $R1 HKLM "${D_INSTALLKEY}" "VersionMinor"
ReadRegDWORD $R2 HKLM "${D_INSTALLKEY}" "VersionRevision"
ReadRegDWORD $R3 HKLM "${D_INSTALLKEY}" "VersionBuild"
StrCpy $R0 $R0.$R1.$R2.$R3
;; identify older versions that did not register their version number in registry
ClearErrors
ReadRegStr $IsOldVerInstalled HKLM "${D_UNINSTALLKEY}" "UninstallString"
IfErrors +2 0
StrCpy $R0 1.0.0.0
${VersionCompare} ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} $R0 $R0
${If} $R0 == 0
StrCpy $R1 "${D_PRODUCT} ${VERSION} is already installed. Select the operation you want to perform and click Next to continue."
StrCpy $R2 "Add/Reinstall components"
StrCpy $R3 "Uninstall ${D_PRODUCT}"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
StrCpy $R0 "2"
${ElseIf} $R0 == 1
StrCpy $R1 "An older version of ${D_PRODUCT} is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
StrCpy $R2 "Uninstall before installing"
StrCpy $R3 "Do not uninstall"
!insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${D_PRODUCT}."
StrCpy $R0 "1"
${ElseIf} $R0 == 2
...
But for some reason it never executes the $R0 == 1 part ("An older version, etc.").
What's wrong in my code?
I also tried
PHP Code:
StrCpy $R0 "1.0.0.0"
instead of
PHP Code:
StrCpy $R0 1.0.0.0
but that didn't help.
What's wrong in my code?