3 Detection functions for all components
\r
7 ;--------------------------------
\r
10 !macro SearchMiKTeX25
\r
12 ;Detect location of MiKTeX installation using initexmf
\r
16 nsExec::ExecToStack "initexmf.exe --report"
\r
17 Pop $R0 ;Return value
\r
20 ${WordFind2X} $R0 "BinDir: " "$\r" "+1" $PathLaTeX
\r
26 !macro SearchMiKTeX24 ROOTKEY
\r
28 ReadRegStr $PathLaTeX ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
\r
30 ${if} $PathLaTeX != ""
\r
31 !insertmacro callfunc TrimBackslash $PathLaTeX $PathLaTeX ;Just in case it's installed in a root directory
\r
32 StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
\r
37 !macro IfKeyExists ROOT MAIN_KEY KEY
\r
42 !define Index 'Line${__LINE__}'
\r
48 EnumRegKey $R0 ${ROOT} "${MAIN_KEY}" "$R1"
\r
49 StrCmp $R0 "" "${Index}-False"
\r
51 StrCmp $R0 "${KEY}" "${Index}-True" "${Index}-Loop"
\r
72 ;--------------------------------
\r
78 Call SearchGhostscript
\r
79 Call SearchImageMagick
\r
86 Function TrimBackslash
\r
88 ;Trim a trailing backslash of a directory
\r
106 Function GetPathPrefix
\r
110 StrCpy $R0 "$INSTDIR\bin;$INSTDIR\python"
\r
112 ${if} $PathLaTeX != ""
\r
113 StrCpy $R0 "$R0;$PathLaTeX"
\r
116 ${if} $PathGhostscript != ""
\r
117 StrCpy $R0 "$R0;$PathGhostscript"
\r
120 ${if} $PathImageMagick != ""
\r
121 StrCpy $R0 "$R0;$PathImageMagick"
\r
128 Function SearchViewer
\r
133 !insertmacro CallFunc DetectViewerByExtension "pdf" $R0
\r
134 !insertmacro CallFunc DetectViewerByExtension "ps" $R1
\r
136 StrCpy $PathViewer ""
\r
140 StrCpy $PathViewer "associated"
\r
149 Function DetectViewerByExtension
\r
151 ;Input on stack: file extension without dot
\r
159 StrCpy $R1 "$PLUGINSDIR\ViewerDetect.$R0"
\r
165 System::Call "shell32::FindExecutableA(t R1, n, t .R0)"
\r
175 Function SearchLaTeX
\r
177 ;Search where MikTeX is installed
\r
179 !insertmacro SearchMiKTeX25
\r
181 ${unless} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
\r
182 !insertmacro SearchMiKTeX24 HKCU
\r
185 ${unless} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
\r
186 !insertmacro SearchMiKTeX24 HKLM
\r
189 ${unless} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
\r
190 StrCpy $PathLatex ""
\r
195 Function SearchLaTeXLocalRoot
\r
197 ;Search for the MikTeX local root
\r
198 ;Returns value on stack
\r
204 !insertmacro IfKeyExists HKCU "Software\MiKTeX.org\MiKTeX" "2.5"
\r
207 ${if} $R0 == ${FALSE}
\r
208 !insertmacro IfKeyExists HKLM "Software\MiKTeX.org\MiKTeX" "2.5"
\r
212 ${if} $R0 == ${TRUE}
\r
213 StrCpy $R0 "$APPDATA\MiKTeX\2.5"
\r
218 ReadRegStr $R0 HKCU "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Local Root"
\r
220 ${unless} ${FileExists} $R0
\r
221 ReadRegStr $R0 HKLM "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Local Root"
\r
230 Function SearchGhostscript
\r
232 ;Search where Ghostscript is installed
\r
236 Push $R2 ;Enum return
\r
237 Push $R3 ;AFPL version
\r
238 Push $R4 ;GPL version
\r
243 ;Check the latest version of AFPL Ghostscript installed
\r
249 EnumRegKey $R2 HKLM "Software\AFPL Ghostscript" $R1
\r
252 ${VersionCompare} $R2 $R3 $R0
\r
259 ${loopuntil} $R2 == ""
\r
261 ;The same for GPL Ghostscript
\r
267 EnumRegKey $R2 HKLM "Software\GPL Ghostscript" $R1
\r
270 ${VersionCompare} $R2 $R4 $R0
\r
277 ${loopuntil} $R2 == ""
\r
279 ;Take the latest one
\r
280 ${VersionCompare} $R3 $R4 $R0
\r
284 ReadRegStr $PathGhostscript HKLM "Software\AFPL Ghostscript\$R3" "GS_DLL"
\r
286 ;GPL is newer or equal
\r
287 ReadRegStr $PathGhostscript HKLM "Software\GPL Ghostscript\$R4" "GS_DLL"
\r
290 ;Trim the DLL filename to get the path
\r
291 ${GetParent} $PathGhostscript $PathGhostscript
\r
293 ${unless} ${FileExists} "$PathGhostscript\${BIN_GHOSTSCRIPT}"
\r
294 StrCpy $PathGhostscript ""
\r
305 Function SearchImageMagick
\r
307 ;Search where ImageMagick is installed
\r
308 ReadRegStr $PathImageMagick HKLM "Software\ImageMagick\Current" "BinPath"
\r
310 ${unless} ${FileExists} "$PathImageMagick\${BIN_IMAGEMAGICK}"
\r
311 StrCpy $PathImageMagick ""
\r