aboutsummaryrefslogtreecommitdiff
path: root/Src/installer/winamp/utils/uninstallInfo.nsh
blob: c95ff5d6e9e3843daa072defb4a085fa281810b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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