aboutsummaryrefslogtreecommitdiff
path: root/Src/installer/winamp/utils/uninstallInfo.nsh
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/installer/winamp/utils/uninstallInfo.nsh
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/installer/winamp/utils/uninstallInfo.nsh')
-rw-r--r--Src/installer/winamp/utils/uninstallInfo.nsh125
1 files changed, 125 insertions, 0 deletions
diff --git a/Src/installer/winamp/utils/uninstallInfo.nsh b/Src/installer/winamp/utils/uninstallInfo.nsh
new file mode 100644
index 00000000..c95ff5d6
--- /dev/null
+++ b/Src/installer/winamp/utils/uninstallInfo.nsh
@@ -0,0 +1,125 @@
+!ifndef NULLSOFT_WINAMP_UNINSTALL_INFO_LIB_HEADER
+!define NULLSOFT_WINAMP_UNINSTALL_INFO_LIB_HEADER
+
+!include "util.nsh"
+
+!define SOFTWARE_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
+
+!macro UninstallInfo_FindProgramKeyHelper __regView __subKey __value __outputVar
+ SetRegView ${__regView}
+ ClearErrors
+ ReadRegStr ${__outputVar} HKCU "${__subkey}" "${__value}"
+ ${IfNot} ${Errors}
+ StrCpy ${__outputVar} "${__regView},HKCU,${__subkey}"
+ ${Else}
+ ClearErrors
+ ReadRegStr ${__outputVar} HKLM "${__subkey}" "${__value}"
+ ${IfNot} ${Errors}
+ StrCpy ${__outputVar} "${__regView},HKLM,${__subkey}"
+ ${Else}
+ StrCpy ${__outputVar} ""
+ ${EndIf}
+ ${EndIf}
+ SetRegView lastused
+!macroend
+
+!define UninstallInfo_FindProgramKeyHelper "!insertmacro 'UninstallInfo_FindProgramKeyHelper'"
+
+!macro UninstallInfo_FindProgramKeyInternal
+ Exch $0
+ Push $1
+
+ StrCpy $1 "${SOFTWARE_UNINSTALL_KEY}\$0"
+ ${UninstallInfo_FindProgramKeyHelper} 32 $1 "UninstallString" $0
+ ${If} $0 == ""
+ ${UninstallInfo_FindProgramKeyHelper} 64 $1 "UninstallString" $0
+ ${If} $0 == ""
+ SetErrors
+ ${EndIf}
+ ${EndIf}
+
+ Pop $1
+ Exch $0
+!macroend
+
+!macro UninstallInfo_FindProgramKey __programName __outputVar
+ Push "${__programName}"
+ ${CallArtificialFunction} UninstallInfo_FindProgramKeyInternal
+ Pop "${__outputVar}"
+!macroend
+
+!define UninstallInfo_FindProgramKey `!insertmacro UninstallInfo_FindProgramKey`
+
+!macro UninstallInfo_GetRegistryValueHelper __regView __readFunc __unparsedPath __value __outputVar
+ SetRegView ${__regView}
+ StrCpy ${__outputVar} "${__unparsedPath}" 4 3
+ ${If} ${__outputVar} == "HKCU"
+ StrCpy ${__outputVar} "${__unparsedPath}" "" 8
+ ${__readFunc} ${__outputVar} HKCU "${__outputVar}" "${__value}"
+ ${ElseIf} ${__outputVar} == "HKLM"
+ StrCpy ${__outputVar} "${__unparsedPath}" "" 8
+ ${__readFunc} ${__outputVar} HKLM "${__outputVar}" "${__value}"
+ ${Else}
+ StrCpy ${__outputVar} ""
+ SetErrors
+ ${EndIf}
+ SetRegView lastused
+!macroend
+
+!define UninstallInfo_GetRegistryValueHelper "!insertmacro 'UninstallInfo_GetRegistryValueHelper'"
+
+!macro UninstallInfo_GetRegistryValueInternal __readFunc
+ Exch $0
+ Exch 1
+ Exch $1 ; path in format VV,KKKK,PATH where VV - registry view (32|64), KKKK - rootkey (HKCU|HKLM), PATH - subkey path
+ Push $2
+
+ StrCpy $2 $1 2 0
+ ${If} $2 == 32
+ ${UninstallInfo_GetRegistryValueHelper} 32 "${__readFunc}" $1 $0 $2
+ ${ElseIf} $2 == 64
+ ${UninstallInfo_GetRegistryValueHelper} 64 "${__readFunc}" $1 $0 $2
+ ${Else}
+ StrCpy $2 ""
+ SetErrors
+ ${EndIf}
+
+ Exch $2
+ Exch 2
+ Pop $0
+ Pop $1
+!macroend
+
+!macro UninstallInfo_GetStringValueInternal
+ !insertmacro 'UninstallInfo_GetRegistryValueInternal' "ReadRegStr"
+!macroend
+
+!macro UninstallInfo_GetDwordValueInternal
+ !insertmacro 'UninstallInfo_GetRegistryValueInternal' "ReadRegDWORD"
+!macroend
+
+!macro UninstallInfo_GetStringValue __programRegPath __valueName __outputVar
+ Push "${__programRegPath}"
+ Push "${__valueName}"
+ ${CallArtificialFunction} UninstallInfo_GetStringValueInternal
+ Pop "${__outputVar}"
+!macroend
+!define UninstallInfo_GetStringValue "!insertmacro 'UninstallInfo_GetStringValue'"
+
+!macro UninstallInfo_GetExpandableStringValue __programRegPath __valueName __outputVar
+ ${UninstallInfo_GetStringValue} "${__programRegPath}" "${__valueName}" "${__outputVar}"
+ ExpandEnvStrings ${__outputVar} "${__outputVar}"
+!macroend
+
+!define UninstallInfo_GetExpandableStringValue "!insertmacro 'UninstallInfo_GetExpandableStringValue'"
+
+!macro UninstallInfo_GetDwordValue __programRegPath __valueName __outputVar
+ Push "${__programRegPath}"
+ Push "${__valueName}"
+ ${CallArtificialFunction} UninstallInfo_GetDwordValueInternal
+ Pop "${__outputVar}"
+!macroend
+
+!define UninstallInfo_GetDwordValue "!insertmacro 'UninstallInfo_GetDwordValue`"
+
+!endif ;NULLSOFT_WINAMP_UNINSTALL_INFO_LIB_HEADER \ No newline at end of file