From e272318725aede94768ce5d96f6c1c8f2ee1ef60 Mon Sep 17 00:00:00 2001 From: joostverburg Date: Wed, 24 Dec 2003 18:38:18 +0000 Subject: [PATCH] UpgradeDLL now supports paths that contain variables git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3312 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/usefulfunc.but | 29 ++++++++++++++++++++--------- Include/UpgradeDLL.nsh | 29 ++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/Docs/src/usefulfunc.but b/Docs/src/usefulfunc.but index d248535e..4dce5d18 100644 --- a/Docs/src/usefulfunc.but +++ b/Docs/src/usefulfunc.but @@ -472,6 +472,8 @@ There is also a copy of this macro in the Include folder, so you only have to in \c Push $R1 \c Push $R2 \c Push $R3 +\c Push $R4 +\c Push $R5 \c \c ;------------------------ \c ;Unique number for labels @@ -479,13 +481,20 @@ There is also a copy of this macro in the Include folder, so you only have to in \c !define UPGRADEDLL_UNIQUE ${__LINE__} \c \c ;------------------------ +\c ;Copy the parameters used on run-time to a variable +\c ;This allows the usage of variables as paramter +\c +\c StrCpy $R4 "${DESTFILE}" +\c StrCpy $R5 "${TEMPBASEDIR}" +\c +\c ;------------------------ \c ;Check file and version \c -\c IfFileExists "${DESTFILE}" 0 upgradedll.copy_${UPGRADEDLL_UNIQUE} +\c IfFileExists $R4 0 upgradedll.copy_${UPGRADEDLL_UNIQUE} \c \c ClearErrors \c GetDLLVersionLocal "${LOCALFILE}" $R0 $R1 -\c GetDLLVersion "${DESTFILE}" $R2 $R3 +\c GetDLLVersion $R4 $R2 $R3 \c IfErrors upgradedll.upgrade_${UPGRADEDLL_UNIQUE} \c \c IntCmpU $R0 $R2 0 upgradedll.done_${UPGRADEDLL_UNIQUE} upgradedll.upgrade_${UPGRADEDLL_UNIQUE} @@ -500,30 +509,30 @@ There is also a copy of this macro in the Include folder, so you only have to in \c upgradedll.upgrade_${UPGRADEDLL_UNIQUE}: \c !ifndef UPGRADEDLL_NOREGISTER \c ;Unregister the DLL -\c UnRegDLL "${DESTFILE}" +\c UnRegDLL $R4 \c !endif \c \c ;------------------------ \c ;Try to copy the DLL directly \c \c ClearErrors -\c StrCpy $R0 "${DESTFILE}" +\c StrCpy $R0 $R4 \c Call :upgradedll.file_${UPGRADEDLL_UNIQUE} \c IfErrors 0 upgradedll.noreboot_${UPGRADEDLL_UNIQUE} \c \c ;------------------------ \c ;DLL is in use. Copy it to a temp file and Rename it on reboot. \c -\c GetTempFileName $R0 "${TEMPBASEDIR}" +\c GetTempFileName $R0 $R5 \c Call :upgradedll.file_${UPGRADEDLL_UNIQUE} -\c Rename /REBOOTOK $R0 "${DESTFILE}" +\c Rename /REBOOTOK $R0 $R4 \c \c ;------------------------ \c ;Register the DLL on reboot \c \c !ifndef UPGRADEDLL_NOREGISTER \c WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" \ -\c "Register ${DESTFILE}" '"$SYSDIR\rundll32.exe" "${DESTFILE}",DllRegisterServer' +\c "Register $R4" '"$SYSDIR\rundll32.exe" "$R4",DllRegisterServer' \c !endif \c \c Goto upgradedll.done_${UPGRADEDLL_UNIQUE} @@ -532,7 +541,7 @@ There is also a copy of this macro in the Include folder, so you only have to in \c ;DLL does not exist - just extract \c \c upgradedll.copy_${UPGRADEDLL_UNIQUE}: -\c StrCpy $R0 "${DESTFILE}" +\c StrCpy $R0 $R4 \c Call :upgradedll.file_${UPGRADEDLL_UNIQUE} \c \c ;------------------------ @@ -540,7 +549,7 @@ There is also a copy of this macro in the Include folder, so you only have to in \c \c upgradedll.noreboot_${UPGRADEDLL_UNIQUE}: \c !ifndef UPGRADEDLL_NOREGISTER -\c RegDLL "${DESTFILE}" +\c RegDLL $R4 \c !endif \c \c ;------------------------ @@ -548,6 +557,8 @@ There is also a copy of this macro in the Include folder, so you only have to in \c \c upgradedll.done_${UPGRADEDLL_UNIQUE}: \c +\c Pop $R5 +\c Pop $R4 \c Pop $R3 \c Pop $R2 \c Pop $R1 diff --git a/Include/UpgradeDLL.nsh b/Include/UpgradeDLL.nsh index fcb62369..233a6fb9 100644 --- a/Include/UpgradeDLL.nsh +++ b/Include/UpgradeDLL.nsh @@ -29,20 +29,29 @@ Push $R1 Push $R2 Push $R3 + Push $R4 + Push $R5 ;------------------------ ;Unique number for labels !define UPGRADEDLL_UNIQUE ${__LINE__} + ;------------------------ + ;Copy the parameters used on run-time to a variable + ;This allows the usage of variables as paramter + + StrCpy $R4 "${DESTFILE}" + StrCpy $R5 "${TEMPBASEDIR}" + ;------------------------ ;Check file and version - IfFileExists "${DESTFILE}" 0 upgradedll.copy_${UPGRADEDLL_UNIQUE} + IfFileExists $R4 0 upgradedll.copy_${UPGRADEDLL_UNIQUE} ClearErrors GetDLLVersionLocal "${LOCALFILE}" $R0 $R1 - GetDLLVersion "${DESTFILE}" $R2 $R3 + GetDLLVersion $R4 $R2 $R3 IfErrors upgradedll.upgrade_${UPGRADEDLL_UNIQUE} IntCmpU $R0 $R2 0 upgradedll.done_${UPGRADEDLL_UNIQUE} upgradedll.upgrade_${UPGRADEDLL_UNIQUE} @@ -57,30 +66,30 @@ upgradedll.upgrade_${UPGRADEDLL_UNIQUE}: !ifndef UPGRADEDLL_NOREGISTER ;Unregister the DLL - UnRegDLL "${DESTFILE}" + UnRegDLL $R4 !endif ;------------------------ ;Try to copy the DLL directly ClearErrors - StrCpy $R0 "${DESTFILE}" + StrCpy $R0 $R4 Call :upgradedll.file_${UPGRADEDLL_UNIQUE} IfErrors 0 upgradedll.noreboot_${UPGRADEDLL_UNIQUE} ;------------------------ ;DLL is in use. Copy it to a temp file and Rename it on reboot. - GetTempFileName $R0 "${TEMPBASEDIR}" + GetTempFileName $R0 $R5 Call :upgradedll.file_${UPGRADEDLL_UNIQUE} - Rename /REBOOTOK $R0 "${DESTFILE}" + Rename /REBOOTOK $R0 $R4 ;------------------------ ;Register the DLL on reboot !ifndef UPGRADEDLL_NOREGISTER WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" \ - "Register ${DESTFILE}" '"$SYSDIR\rundll32.exe" "${DESTFILE}",DllRegisterServer' + "Register $R4" '"$SYSDIR\rundll32.exe" "$R4",DllRegisterServer' !endif Goto upgradedll.done_${UPGRADEDLL_UNIQUE} @@ -89,7 +98,7 @@ ;DLL does not exist - just extract upgradedll.copy_${UPGRADEDLL_UNIQUE}: - StrCpy $R0 "${DESTFILE}" + StrCpy $R0 $R4 Call :upgradedll.file_${UPGRADEDLL_UNIQUE} ;------------------------ @@ -97,7 +106,7 @@ upgradedll.noreboot_${UPGRADEDLL_UNIQUE}: !ifndef UPGRADEDLL_NOREGISTER - RegDLL "${DESTFILE}" + RegDLL $R4 !endif ;------------------------ @@ -105,6 +114,8 @@ upgradedll.done_${UPGRADEDLL_UNIQUE}: + Pop $R5 + Pop $R4 Pop $R3 Pop $R2 Pop $R1