Debian Codegraph @

altosui/Instdrv/NSIS/Includes/java.nsh

raw
1 !include WordFunc.nsh
2
3 ; Definitions for Java Detection
4
5 !define JAVA_VERSION "6.0"
6
7 Function GetFileVersion
8 !define GetFileVersion `!insertmacro GetFileVersionCall`
9
10 !macro GetFileVersionCall _FILE _RESULT
11 Push `${_FILE}`
12 Call GetFileVersion
13 Pop ${_RESULT}
14 !macroend
15
16 Exch $0
17 Push $1
18 Push $2
19 Push $3
20 Push $4
21 Push $5
22 Push $6
23 ClearErrors
24
25 GetDllVersion '$0' $1 $2
26 IfErrors error
27 IntOp $3 $1 >> 16
28 IntOp $3 $3 & 0x0000FFFF
29 IntOp $4 $1 & 0x0000FFFF
30 IntOp $5 $2 >> 16
31 IntOp $5 $5 & 0x0000FFFF
32 IntOp $6 $2 & 0x0000FFFF
33 StrCpy $0 '$3.$4.$5.$6'
34 goto end
35
36 error:
37 SetErrors
38 StrCpy $0 ''
39
40 end:
41 Pop $6
42 Pop $5
43 Pop $4
44 Pop $3
45 Pop $2
46 Pop $1
47 Exch $0
48 FunctionEnd
49
50 Function openLinkNewWindow
51 Push $3
52 Exch
53 Push $2
54 Exch
55 Push $1
56 Exch
57 Push $0
58 Exch
59
60 ReadRegStr $1 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice" "Progid"
61 IfErrors iexplore
62
63 Goto foundbrowser
64 iexplore:
65 StrCpy $1 "IE.AssocFile.HTM"
66
67 foundbrowser:
68
69 StrCpy $2 "\shell\open\command"
70
71 StrCpy $3 $1$2
72
73 ReadRegStr $0 HKCR $3 ""
74
75 # Get browser path
76 DetailPrint $0
77
78 StrCpy $2 '"'
79 StrCpy $1 $0 1
80 StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char
81 StrCpy $2 ' '
82 StrCpy $3 1
83 loop:
84 StrCpy $1 $0 1 $3
85 DetailPrint $1
86 StrCmp $1 $2 found
87 StrCmp $1 "" found
88 IntOp $3 $3 + 1
89 Goto loop
90
91 found:
92 StrCpy $1 $0 $3
93 StrCmp $2 " " +2
94 StrCpy $1 '$1"'
95
96 Pop $0
97 Exec '$1 $0'
98 Pop $0
99 Pop $1
100 Pop $2
101 Pop $3
102 FunctionEnd
103
104 !macro _OpenURL URL
105 Push "${URL}"
106 Call openLinkNewWindow
107 !macroend
108
109 !define OpenURL '!insertmacro "_OpenURL"'
110
111 Function DoDetectJRE
112
113 DetailPrint "Desired Java version ${JAVA_VERSION}"
114
115 SearchPath $0 javaw.exe
116 IfErrors no
117
118 DetailPrint "Detected java in $0"
119
120 ${GetFileVersion} "$0" $1
121 IfErrors no
122
123 DetailPrint "Java version $1"
124
125 ${VersionCompare} $1 ${JAVA_VERSION} $2
126 IntCmp $2 1 yes yes old
127
128 yes:
129 StrCpy $0 2
130 Goto done
131
132 old:
133 StrCpy $0 1
134 Goto done
135
136 no:
137 StrCpy $0 0
138 Goto done
139
140 done:
141
142 FunctionEnd
143
144 var dialog
145 var hwnd
146 var null
147
148 var install
149 var quit
150 var skip
151
152 Function GetJRE
153 ${OpenURL} "adoptium.net"
154 MessageBox MB_OK "Click OK to continue after completing the Java Install."
155 FunctionEnd
156
157 Function DetectJRE
158
159 Call DoDetectJRE
160
161 IntCmp $0 1 ask_old ask_no yes
162
163 ask_no:
164 StrCpy $0 "Cannot find Java. Download and install?"
165 Goto ask
166
167 ask_old:
168 StrCpy $0 "Java version appears to be too old. Download and install?"
169 Goto ask
170
171 ask:
172 MessageBox MB_YESNOCANCEL $0 IDYES do_java IDNO skip_java
173
174 do_java:
175 Call GetJRE
176
177
178 skip_java:
179 yes:
180
181 FunctionEnd