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
36 !macro SEARCH_MIKTEX24 ROOTKEY
38 ReadRegStr $PathLaTeX ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
40 ${If} $PathLaTeX != ""
41 StrCpy $LastChar $PathLaTeX 1 -1
42 ${If} $LastChar == "\"
44 StrLen $PathLength $PathLaTeX
45 IntOp $PathLength $PathLength - 1
46 StrCpy $PathLaTeX $PathLaTeX $PathLength
48 StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
55 # Search where MikTeX is installed
57 !insertmacro SEARCH_MIKTEX25
59 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
60 !insertmacro SEARCH_MIKTEX24 HKCU
63 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
64 !insertmacro SEARCH_MIKTEX24 HKLM
67 ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
73 #--------------------------------
82 Function SearchGhostscript
84 # Search where Ghostscript is installed
86 # Find the latest version of AFPL Ghostscript installed
92 EnumRegKey $EnumReturn HKLM "Software\AFPL Ghostscript" $Counter
94 ${If} $EnumReturn != ""
95 ${VersionCompare} $EnumReturn $AFPLVersion $CompareReturn
96 ${If} $CompareReturn == "1"
97 StrCpy $AFPLVersion $EnumReturn
99 IntOp $Counter $Counter + 1
102 ${loopuntil} $EnumReturn == ""
104 # The same for GPL Ghostscript
110 EnumRegKey $EnumReturn HKLM "Software\GPL Ghostscript" $Counter
112 ${If} $EnumReturn != ""
113 ${VersionCompare} $EnumReturn $GPLVersion $CompareReturn
114 ${If} $CompareReturn == "1"
115 StrCpy $GPLVersion $EnumReturn
117 IntOp $Counter $Counter + 1
120 ${loopuntil} $EnumReturn == ""
122 # Take the latest one
123 ${VersionCompare} $AFPLVersion $GPLVersion $CompareReturn
125 ${If} $CompareReturn = 1
127 ReadRegStr $PathGhostscript HKLM "Software\AFPL Ghostscript\$R3" "GS_DLL"
129 # GPL is newer or equal
130 ReadRegStr $PathGhostscript HKLM "Software\GPL Ghostscript\$R4" "GS_DLL"
133 # Trim the DLL filename to get the path
134 ${GetParent} $PathGhostscript $PathGhostscript
136 ${IfNot} ${FileExists} "$PathGhostscript\${BIN_GHOSTSCRIPT}"
137 StrCpy $PathGhostscript ""
142 #--------------------------------
145 Function SearchImageMagick
147 # Search where ImageMagick is installed
148 ReadRegStr $PathImageMagick HKLM "Software\ImageMagick\Current" "BinPath"
150 ${IfNot} ${FileExists} "$PathImageMagick\${BIN_IMAGEMAGICK}"
151 StrCpy $PathImageMagick ""