]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/MissingPrograms.nsh
Changed comment character from ';' to '#*
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / MissingPrograms.nsh
1 Function MissingPrograms
2
3   # initialize variable, is later set to True when a program was not found
4   StrCpy $MissedProg "False"
5
6   # test if Ghostscript is installed
7   GSloop:
8   EnumRegKey $1 HKLM "Software\AFPL Ghostscript" 0
9   ${if} $1 == ""
10    EnumRegKey $1 HKLM "Software\GPL Ghostscript" 0
11    ${if} $1 != ""
12     StrCpy $2 "True"
13    ${endif}
14   ${endif}
15   ${if} $1 != ""
16    ${if} $2 == "True"
17     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPL Ghostscript $1" "DisplayName"
18     StrCpy $0 "Software\GPL Ghostscript\$1"
19    ${else}
20     ReadRegStr $3 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AFPL Ghostscript $1" "DisplayName"
21     StrCpy $0 "Software\AFPL Ghostscript\$1"
22    ${endif}
23    ${if} $3 == "" # if nothing was found in the uninstall section
24     ReadRegStr $3 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" # check if Ghostscript was installed together with LyX
25    ${endif}
26    ${if} $3 == "" # if nothing was found in the uninstall section
27     DeleteRegKey HKLM "$0"
28     goto GSloop
29    ${else}
30     ReadRegStr $GhostscriptPath HKLM $0 "GS_DLL"
31     ${if} $GhostscriptPath != ""
32      StrCpy $GhostscriptPath "$GhostscriptPath" -12 # remove ending "gsdll32.dll"
33     ${else}
34      StrCpy $MissedProg "True"
35     ${endif}
36    ${endif} # if $3
37   ${else} # if $1
38    StrCpy $GhostscriptPath ""
39    StrCpy $MissedProg "True"
40   ${endif}
41
42   # test if Imagemagick is installed
43   ReadRegStr $ImageMagickPath HKLM "Software\ImageMagick\Current" "BinPath"
44   ${if} $ImageMagickPath == ""
45    StrCpy $MissedProg "True"
46   ${endif}
47
48   # test if Aiksaurus is installed
49   !insertmacro FileCheck $5 "meanings.dat" "${AiksaurusDir}" # macro from LyXUtils.nsh
50   ${if} $5 == "True"
51    StrCpy $AiksaurusPath "${AiksaurusDir}"
52   ${endif}
53 #  ReadRegStr $AiksaurusPath HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "AIK_DATA_DIR"
54
55   # test if Aspell is installed
56   StrCpy $5 ""
57   ReadRegStr $5 HKCU "SOFTWARE\Aspell" "Base Path"
58   ${if} $5 == ""
59    ReadRegStr $5 HKLM "SOFTWARE\Aspell" "Base Path"
60    StrCpy $AspellBaseReg "HKLM" # used in the aspell installation section
61   ${else}
62    StrCpy $AspellBaseReg "HKCU"
63   ${endif}
64   ${if} $5 == ""
65    StrCpy $MissedProg "True"
66   ${else}
67    StrCpy $AspellPath "$5"
68   ${endif}
69
70   # test if Python is installed
71   # only use an existing python when it is version 2.5 because many Compaq and Dell PC are delivered
72   # with outdated Python interpreters
73   ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
74   ${if} $PythonPath != ""
75    StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
76    StrCpy $DelPythonFiles "True"
77   ${endif}
78
79   # test if Acrobat or Adobe Reader is used as PDF-viewer
80   ReadRegStr $String HKCR ".pdf" ""
81   ${if} $String != "AcroExch.Document" # this name is only used by Acrobat and Adobe Reader
82    StrCpy $Acrobat "None"
83   ${endif}
84   ${if} $Acrobat != "None"
85    ReadRegStr $String HKCR "AcroExch.Document\shell\open\command" ""
86    StrCpy $Search "8" # search for Acrobat or Adobe Reader 8 because then PDFViewWin8.exe is needed to view PDF-files
87    !insertmacro StrPointer $String $Search $Pointer # macro from LyXUtils
88    ${if} $Pointer == "-1" # if nothing was found
89     StrCpy $Acrobat "7"
90    ${else}
91     StrCpy $Acrobat "8"
92    ${endif}
93   ${endif}
94
95   # test if a PostScript-viewer is installed, only check for GSview32
96   StrCpy $PSVPath ""
97   ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
98
99   # test if an editor with syntax-highlighting for LaTeX-files is installed
100   Call EditorCheck
101
102   # test if an image editor is installed (due to LyX's bug 2654 first check for GIMP)
103   StrCpy $ImageEditorPath ""
104   ReadRegStr $ImageEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinGimp-2.0_is1" "DisplayIcon"
105   ${if} $ImageEditorPath != ""
106    StrCpy $ImageEditorPath "$ImageEditorPath" -13 # delete "\gimp-2.x.exe"
107   ${endif}
108   # check for Photoshop
109   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Photoshop.exe" "Path"
110   ${if} $0 != ""
111    StrCpy $0 "$0" -1 # delete the last "\"
112    ${if} $ImageEditorPath != ""
113     StrCpy $ImageEditorPath "$ImageEditorPath;$0"
114    ${else}
115     StrCpy $ImageEditorPath $0
116    ${endif}
117   ${endif}
118
119   # test if the BibTeX-editor JabRef is installed
120   StrCpy $BibTeXEditorPath ""
121   ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.1" "UninstallString"
122   ${if} $BibTeXEditorPath == ""
123    ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef 2.2" "UninstallString"
124   ${endif}
125
126 FunctionEnd
127
128 # ---------------------------------------
129
130 Function MissingProgramsPage
131
132   # generate the installer page - re-read empty page first
133   StrCpy $0 "2"
134   !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io_missing_progs.ini"
135   !insertmacro MUI_HEADER_TEXT "$(MissProgHeader)" ""
136   
137   ${if} $MissedProg == "False"
138    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 6" "Text" "$(MissProgMessage)"
139   ${else}
140    !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field 1" "Text" "$(MissProgCap)"
141    ${if} ${INSTALLER_VERSION} == "Complete"
142     ${if} $LatexPath == ""
143      !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgLatex)"
144      IntOp $0 $0 + 1
145     ${endif}
146    ${endif}
147    ${if} $GhostscriptPath == ""
148     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgGhostscript)"
149     IntOp $0 $0 + 1
150    ${endif}
151    ${if} $ImageMagickPath == ""
152     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgImageMagick)"
153     IntOp $0 $0 + 1
154    ${endif}
155    ${if} $AspellPath == ""
156     !insertmacro MUI_INSTALLOPTIONS_WRITE "io_missing_progs.ini" "Field $0" "Text" "$(MissProgAspell)"
157    ${endif}
158   ${endif}
159   
160   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io_missing_progs.ini"
161
162 FunctionEnd
163
164 # ---------------------------------------
165
166 Function MissingProgramsPage_LeaveFunction
167
168  # this function is needed for the installer page
169
170 FunctionEnd
171
172 # ---------------------------------------
173
174 Function EditorCheck
175
176   # test if an editor with syntax-highlighting for LaTeX-files is installed
177   # (check for jEdit, PSPad, WinShell, ConTEXT, Crimson Editor, Vim, TeXnicCenter, LaTeXEditor, WinEdt, LEd, WinTeX)
178   StrCpy $EditorPath ""
179   StrCpy $0 ""
180   # check for jEdit
181   ReadRegStr $EditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\jEdit_is1" "InstallLocation"
182   ${if} $EditorPath != ""
183    StrCpy $EditorPath $EditorPath -1 # remove "\" from the end of the string
184   ${endif}
185   # check for PSPad
186   StrCpy $0 ""
187   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PSPad editor_is1" "InstallLocation"
188   ${if} $0 != ""
189    StrCpy $0 $0 -1
190    StrCpy $EditorPath "$EditorPath;$0"
191   ${endif}
192   # check for WinShell
193   StrCpy $0 ""
194   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinShell_is1" "InstallLocation"
195   ${if} $0 != ""
196    StrCpy $0 $0 -1
197    StrCpy $EditorPath "$EditorPath;$0"
198   ${endif}
199   # check for ConTEXT
200   StrCpy $0 ""
201   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ConTEXTEditor_is1" "InstallLocation"
202   ${if} $0 != ""
203    StrCpy $0 $0 -1
204    StrCpy $EditorPath "$EditorPath;$0"
205   ${endif}
206   # check for Crimson Editor
207   StrCpy $0 ""
208   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Crimson Editor" "UninstallString"
209   ${if} $0 != ""
210    StrCpy $0 $0 -14 # remove "\uninstall.exe"
211    StrCpy $EditorPath "$EditorPath;$0"
212   ${endif}
213   # check for Vim 6.x
214   StrCpy $0 ""
215   ReadRegStr $0 HKLM "Software\Classes\Applications\gvim.exe\shell\edit\command" ""
216   ${if} $0 != ""
217    StrCpy $0 $0 -13 # remove "gvim.exe "%1""
218    StrCpy $EditorPath "$EditorPath;$0"
219   ${endif}
220   # check for Vim 7.0
221   StrCpy $0 ""
222   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Vim 7.0" "UninstallString"
223   ${if} $0 != ""
224    StrCpy $0 $0 -18 # remove "\uninstall-gui.exe"
225    StrCpy $EditorPath "$EditorPath;$0"
226   ${endif}
227   # check for TeXnicCenter
228   StrCpy $0 ""
229   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TeXnicCenter_is1" "Inno Setup: App Path"
230   ${if} $0 != ""
231    StrCpy $EditorPath "$EditorPath;$0"
232   ${endif}
233   # check for LaTeXEditor
234   StrCpy $0 ""
235   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LaTeX Editor" "InstallLocation"
236   ${if} $0 != ""
237    StrCpy $EditorPath "$EditorPath;$0"
238   ${endif}
239   # check for WinEdt
240   StrCpy $0 ""
241   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinEdt_is1" "InstallLocation"
242   ${if} $0 != ""
243    StrCpy $0 $0 -1
244    StrCpy $EditorPath "$EditorPath;$0"
245   ${endif}
246   # check for LEd
247   StrCpy $0 ""
248   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LEd_is1" "InstallLocation"
249   ${if} $0 != ""
250    StrCpy $0 $0 -1
251    StrCpy $EditorPath "$EditorPath;$0"
252   ${endif}
253   # check for WinTeX
254   StrCpy $0 ""
255   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\WinTeX XP" "DisplayIcon"
256   ${if} $0 != ""
257    StrCpy $0 $0 -11 # remove "\wintex.exe"
258    StrCpy $EditorPath "$EditorPath;$0"
259   ${endif}
260
261 FunctionEnd
262