5 Detection of external component locations
9 Function SearchExternal
11 Call SearchBibTeXEditor
12 !ifndef BUNDLE_IMAGEMAGICK
13 Call SearchImageMagick
15 !ifndef BUNDLE_GHOSTSCRIPT
16 Call SearchGhostscript
20 #--------------------------------
28 !macro SEARCH_MIKTEX25
30 # Search location of MiKTeX installation using initexmf
31 # Works for version 2.5 and later
33 nsExec::ExecToStack "initexmf.exe --report"
35 Pop $CommandLineOutput
37 ${WordFind2X} $CommandLineOutput "BinDir: " "$\r" "+1" $PathLaTeX
38 ${WordFind2X} $CommandLineOutput "CommonData: " "$\r" "+1" $PathLaTeXLocal # Local root
42 !macro SEARCH_MIKTEX24 ROOTKEY
44 ReadRegStr $PathLaTeX ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
46 ${If} $PathLaTeX != ""
47 StrCpy $LastChar $PathLaTeX 1 -1
49 ${If} $LastChar == "\"
51 StrLen $PathLength $PathLaTeX
52 IntOp $PathLength $PathLength - 1
53 StrCpy $PathLaTeX $PathLaTeX $PathLength
56 StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
59 ReadRegStr $PathLaTeXLocal ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Local Root"
67 # Search where MikTeX is installed
69 !insertmacro SEARCH_MIKTEX25
71 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
72 !insertmacro SEARCH_MIKTEX24 HKCU
75 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
76 !insertmacro SEARCH_MIKTEX24 HKLM
79 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
85 #--------------------------------
88 !ifndef BUNDLE_GHOSTSCRIPT
90 !insertmacro GetParent
91 !insertmacro VersionCompare
99 Function SearchGhostscript
101 # Search where Ghostscript is installed
103 # Find the latest version of AFPL Ghostscript installed
109 EnumRegKey $EnumReturn HKLM "Software\AFPL Ghostscript" $Counter
111 ${If} $EnumReturn != ""
112 ${VersionCompare} $EnumReturn $AFPLVersion $CompareReturn
113 ${If} $CompareReturn == "1"
114 StrCpy $AFPLVersion $EnumReturn
116 IntOp $Counter $Counter + 1
119 ${loopuntil} $EnumReturn == ""
121 # The same for GPL Ghostscript
127 EnumRegKey $EnumReturn HKLM "Software\GPL Ghostscript" $Counter
129 ${If} $EnumReturn != ""
130 ${VersionCompare} $EnumReturn $GPLVersion $CompareReturn
131 ${If} $CompareReturn == "1"
132 StrCpy $GPLVersion $EnumReturn
134 IntOp $Counter $Counter + 1
137 ${loopuntil} $EnumReturn == ""
139 # Take the latest one
140 ${VersionCompare} $AFPLVersion $GPLVersion $CompareReturn
142 ${If} $CompareReturn = 1
144 ReadRegStr $PathGhostscript HKLM "Software\AFPL Ghostscript\$R3" "GS_DLL"
146 # GPL is newer or equal
147 ReadRegStr $PathGhostscript HKLM "Software\GPL Ghostscript\$R4" "GS_DLL"
150 # Trim the DLL filename to get the path
151 ${GetParent} $PathGhostscript $PathGhostscript
153 ${IfNot} ${FileExists} "$PathGhostscript\${BIN_GHOSTSCRIPT}"
154 StrCpy $PathGhostscript ""
161 #--------------------------------
164 !ifndef BUNDLE_IMAGEMAGICK
166 Function SearchImageMagick
168 # Search where ImageMagick is installed
169 ReadRegStr $PathImageMagick HKLM "Software\ImageMagick\Current" "BinPath"
171 ${IfNot} ${FileExists} "$PathImageMagick\${BIN_IMAGEMAGICK}"
172 StrCpy $PathImageMagick ""
179 #--------------------------------
182 Function SearchBibTeXEditor
184 # Search where JabRef is installed
185 ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
187 ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
188 ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
191 ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
192 StrCpy $PathBibTeXEditor ""