5 Detection of external component locations
9 Function SearchExternal
11 Call SearchGhostscript
12 Call SearchImageMagick
15 #--------------------------------
23 !macro SEARCH_MIKTEX25
25 # Search location of MiKTeX installation using initexmf
26 # Works for version 2.5 and later
28 nsExec::ExecToStack "initexmf.exe --report"
30 Pop $CommandLineOutput
32 ${WordFind2X} $CommandLineOutput "BinDir: " "$\r" "+1" $PathLaTeX
33 ${WordFind2X} $CommandLineOutput "CommonData: " "$\r" "+1" $PathLaTeXLocal # Local root
37 !macro SEARCH_MIKTEX24 ROOTKEY
39 ReadRegStr $PathLaTeX ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
41 ${If} $PathLaTeX != ""
42 StrCpy $LastChar $PathLaTeX 1 -1
44 ${If} $LastChar == "\"
46 StrLen $PathLength $PathLaTeX
47 IntOp $PathLength $PathLength - 1
48 StrCpy $PathLaTeX $PathLaTeX $PathLength
51 StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
54 ReadRegStr $PathLaTeXLocal ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Local Root"
62 # Search where MikTeX is installed
64 !insertmacro SEARCH_MIKTEX25
66 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
67 !insertmacro SEARCH_MIKTEX24 HKCU
70 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
71 !insertmacro SEARCH_MIKTEX24 HKLM
74 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
80 #--------------------------------
89 Function SearchGhostscript
91 # Search where Ghostscript is installed
93 # Find the latest version of AFPL Ghostscript installed
99 EnumRegKey $EnumReturn HKLM "Software\AFPL Ghostscript" $Counter
101 ${If} $EnumReturn != ""
102 ${VersionCompare} $EnumReturn $AFPLVersion $CompareReturn
103 ${If} $CompareReturn == "1"
104 StrCpy $AFPLVersion $EnumReturn
106 IntOp $Counter $Counter + 1
109 ${loopuntil} $EnumReturn == ""
111 # The same for GPL Ghostscript
117 EnumRegKey $EnumReturn HKLM "Software\GPL Ghostscript" $Counter
119 ${If} $EnumReturn != ""
120 ${VersionCompare} $EnumReturn $GPLVersion $CompareReturn
121 ${If} $CompareReturn == "1"
122 StrCpy $GPLVersion $EnumReturn
124 IntOp $Counter $Counter + 1
127 ${loopuntil} $EnumReturn == ""
129 # Take the latest one
130 ${VersionCompare} $AFPLVersion $GPLVersion $CompareReturn
132 ${If} $CompareReturn = 1
134 ReadRegStr $PathGhostscript HKLM "Software\AFPL Ghostscript\$R3" "GS_DLL"
136 # GPL is newer or equal
137 ReadRegStr $PathGhostscript HKLM "Software\GPL Ghostscript\$R4" "GS_DLL"
140 # Trim the DLL filename to get the path
141 ${GetParent} $PathGhostscript $PathGhostscript
143 ${IfNot} ${FileExists} "$PathGhostscript\${BIN_GHOSTSCRIPT}"
144 StrCpy $PathGhostscript ""
149 #--------------------------------
152 Function SearchImageMagick
154 # Search where ImageMagick is installed
155 ReadRegStr $PathImageMagick HKLM "Software\ImageMagick\Current" "BinPath"
157 ${IfNot} ${FileExists} "$PathImageMagick\${BIN_IMAGEMAGICK}"
158 StrCpy $PathImageMagick ""