forked from Tobbe/losi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PagePreviousInstall.nsh
115 lines (92 loc) · 2.55 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
109
110
111
112
113
114
115
!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 == "detected"
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)" ""
!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
Push $R2
ReadRegStr $R2 HKCU "Software\LiteStep\Installer" "LiteStepDir"
IfErrors 0 +2
ReadRegStr $R2 HKLM "Software\LOSI\Installer" "LitestepDir"
ClearErrors
${If} $R2 == $INSTDIR
StrCpy $R0 "upgrade"
GoTo PrevInstDetectionEnd
${EndIf}
; remove trailing backslash if there is one
StrCpy $R1 $R2 1 -1
StrCmp $R1 "\" 0 +2
StrCpy $R2 $R2 -1
${If} $R2 == $INSTDIR
StrCpy $R0 "upgrade"
GoTo PrevInstDetectionEnd
${EndIf}
StrCpy $R2 "$R2\litestep.exe"
IfFileExists $R2 PrevInstDetected
FindProcDLL::FindProc "litestep.exe"
StrCmp $R2 1 PrevInstDetected
; Check the most common installation directories
IfFileExists "C:\LiteStep\litestep.exe" PrevInstDetected
IfFileExists "$PROGRAMFILES\LiteStep\litestep.exe" PrevInstDetected
; For Win9x
ReadINIStr $R2 "$WINDIR\system.ini" "boot" "shell"
StrCpy $R2 $R2 "" -12 ; Copy the last twelve characters
${If} $R2 == "litestep.exe"
GoTo PrevInstDetected
${EndIf}
StrCpy $R0 "notdetected"
GoTo PrevInstDetectionEnd
PrevInstDetected:
StrCpy $R0 "detected"
PrevInstDetectionEnd:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
!endif