2007-02-08 21:09:30 +00:00
|
|
|
/*
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
detection.nsh
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Detection of external component locations
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
*/
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Function SearchExternal
|
2007-02-08 21:09:30 +00:00
|
|
|
Call SearchLaTeX
|
|
|
|
Call SearchGhostscript
|
|
|
|
Call SearchImageMagick
|
|
|
|
FunctionEnd
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
#--------------------------------
|
|
|
|
# MiKTeX
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Var ProcessReturn
|
|
|
|
Var CommandLineOutput
|
|
|
|
Var LastChar
|
|
|
|
Var PathLength
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!macro SEARCH_MIKTEX25
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Search location of MiKTeX installation using initexmf
|
|
|
|
# Works for version 2.5 and later
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
nsExec::ExecToStack "initexmf.exe --report"
|
|
|
|
Pop $ProcessReturn
|
|
|
|
Pop $CommandLineOutput
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${WordFind2X} $CommandLineOutput "BinDir: " "$\r" "+1" $PathLaTeX
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!macroend
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!macro SEARCH_MIKTEX24 ROOTKEY
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
ReadRegStr $PathLaTeX ${ROOTKEY} "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" "Install Root"
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${If} $PathLaTeX != ""
|
|
|
|
StrCpy $LastChar $PathLaTeX 1 -1
|
|
|
|
${If} $LastChar == "\"
|
|
|
|
# Trim backslash
|
|
|
|
StrLen $PathLength $PathLaTeX
|
|
|
|
IntOp $PathLength $PathLength - 1
|
|
|
|
StrCpy $PathLaTeX $PathLaTeX $PathLength
|
|
|
|
${EndIf}
|
|
|
|
StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!macroend
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Function SearchLaTeX
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Search where MikTeX is installed
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
!insertmacro SEARCH_MIKTEX25
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
|
|
|
|
!insertmacro SEARCH_MIKTEX24 HKCU
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
|
|
|
|
!insertmacro SEARCH_MIKTEX24 HKLM
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
|
2007-02-08 21:09:30 +00:00
|
|
|
StrCpy $PathLatex ""
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
#--------------------------------
|
|
|
|
# Ghostscript
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
Var Counter
|
|
|
|
Var EnumReturn
|
|
|
|
Var CompareReturn
|
|
|
|
Var AFPLVersion
|
|
|
|
Var GPLVersion
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
Function SearchGhostscript
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Search where Ghostscript is installed
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Find the latest version of AFPL Ghostscript installed
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
StrCpy $Counter 0
|
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
${do}
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
EnumRegKey $EnumReturn HKLM "Software\AFPL Ghostscript" $Counter
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${If} $EnumReturn != ""
|
|
|
|
${VersionCompare} $EnumReturn $AFPLVersion $CompareReturn
|
|
|
|
${If} $CompareReturn == "1"
|
|
|
|
StrCpy $AFPLVersion $EnumReturn
|
|
|
|
${EndIf}
|
|
|
|
IntOp $Counter $Counter + 1
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${loopuntil} $EnumReturn == ""
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# The same for GPL Ghostscript
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
StrCpy $Counter 0
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
${do}
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
EnumRegKey $EnumReturn HKLM "Software\GPL Ghostscript" $Counter
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${If} $EnumReturn != ""
|
|
|
|
${VersionCompare} $EnumReturn $GPLVersion $CompareReturn
|
|
|
|
${If} $CompareReturn == "1"
|
|
|
|
StrCpy $GPLVersion $EnumReturn
|
|
|
|
${EndIf}
|
|
|
|
IntOp $Counter $Counter + 1
|
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${loopuntil} $EnumReturn == ""
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Take the latest one
|
|
|
|
${VersionCompare} $AFPLVersion $GPLVersion $CompareReturn
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${If} $CompareReturn = 1
|
|
|
|
# AFPL is newer
|
2007-02-08 21:09:30 +00:00
|
|
|
ReadRegStr $PathGhostscript HKLM "Software\AFPL Ghostscript\$R3" "GS_DLL"
|
2008-03-30 21:37:53 +00:00
|
|
|
${Else}
|
|
|
|
# GPL is newer or equal
|
2007-02-08 21:09:30 +00:00
|
|
|
ReadRegStr $PathGhostscript HKLM "Software\GPL Ghostscript\$R4" "GS_DLL"
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Trim the DLL filename to get the path
|
2007-02-08 21:09:30 +00:00
|
|
|
${GetParent} $PathGhostscript $PathGhostscript
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${FileExists} "$PathGhostscript\${BIN_GHOSTSCRIPT}"
|
2007-02-08 21:09:30 +00:00
|
|
|
StrCpy $PathGhostscript ""
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
|
|
|
FunctionEnd
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
#--------------------------------
|
|
|
|
# ImageMagick
|
|
|
|
|
2007-02-08 21:09:30 +00:00
|
|
|
Function SearchImageMagick
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
# Search where ImageMagick is installed
|
2007-02-08 21:09:30 +00:00
|
|
|
ReadRegStr $PathImageMagick HKLM "Software\ImageMagick\Current" "BinPath"
|
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
${IfNot} ${FileExists} "$PathImageMagick\${BIN_IMAGEMAGICK}"
|
2007-02-08 21:09:30 +00:00
|
|
|
StrCpy $PathImageMagick ""
|
2008-03-30 21:37:53 +00:00
|
|
|
${EndIf}
|
2007-02-08 21:09:30 +00:00
|
|
|
|
2008-03-30 21:37:53 +00:00
|
|
|
FunctionEnd
|