-
Notifications
You must be signed in to change notification settings - Fork 13
/
PagePreviousInstall.nsh
108 lines (87 loc) · 2.47 KB
/
PagePreviousInstall.nsh
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
!ifndef PAGE_PREVIOUS_INSTALL
!define PAGE_PREVIOUS_INSTALL
!include LogicLib.nsh
Page custom ioPrevInst ioPrevInstLeave
Function ioPrevInst
Push $R0
Push $R1
Push $R2
Push $R3
Push $R4
Push $R5
Call DetectPreviousInstall
Pop $R0
${If} $R0 != "notdetected"
WriteINIStr "$PLUGINSDIR\ioPreviousInstall.ini" "Field 1" "Text" "$(PREVINST_TEXT)"
WriteINIStr "$PLUGINSDIR\ioPreviousInstall.ini" "Field 2" "Text" "$(PREVINST_CHECKBOX)"
!insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_PREVINST)" "$(TEXT_IO_PREVINST)"
!insertmacro INSTALLOPTIONS_INITDIALOG "ioPreviousInstall.ini"
GetDlgItem $R1 $HWNDPARENT 1
EnableWindow $R1 0
StrCpy $abortWarning "false"
!insertmacro INSTALLOPTIONS_SHOW
${EndIf}
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
Function ioPrevInstLeave
Push $R0
Push $R1
ReadINIStr $R0 "$PLUGINSDIR\ioPreviousInstall.ini" "Settings" "State"
ReadINIStr $R1 "$PLUGINSDIR\ioPreviousInstall.ini" "Field 2" "State"
${If} $R0 != 0
GetDlgItem $R0 $HWNDPARENT 1
${If} $R1 == 1
StrCpy $abortWarning "true"
EnableWindow $R0 1
${Else}
StrCpy $abortWarning "false"
EnableWindow $R0 0
${EndIf}
Abort
${EndIf}
Pop $R1
Pop $R0
FunctionEnd
Function DetectPreviousInstall
Push $R0
Push $R1
ReadRegStr $R0 HKCU "Software\LiteStep\Installer" "LiteStepDir"
IfErrors 0 +3
ReadRegStr $R0 HKLM "Software\LOSI\Installer" "LitestepDir"
IfErrors PrevInstNotDetected
${If} $R0 == $INSTDIR
Push "upgrade"
GoTo PrevInstDetectionEnd
${EndIf}
; remove trailing backslash if there is one
StrCpy $R1 $R0 1 -1
StrCmp $R1 "\" 0 +2
StrCpy $R0 $R0 -1
StrCpy $R0 "$R0\litestep.exe"
IfFileExists $R0 PrevInstDetected
FindProcDLL::FindProc "litestep.exe"
StrCmp $R0 1 PrevInstDetected
; Check the most common installation directories
IfFileExists "C:\LiteStep\litestep.exe" PrevInstDetected
IfFileExists "$PROGRAMFILES\LiteStep\litestep.exe" PrevInstDetected
; For Win9x
ReadINIStr $R0 "$WINDIR\system.ini" "boot" "shell"
StrCpy $R0 $R0 "" -12 ; Copy the last twelve characters
${If} $R0 == "litestep.exe"
GoTo PrevInstDetected
${EndIf}
PrevInstNotDetected:
Push "notdetected"
GoTo PrevInstDetectionEnd
PrevInstDetected:
Push "detected"
PrevInstDetectionEnd:
Pop $R1
Pop $R0
FunctionEnd
!endif