Hello Angus,

as promised attached a patch that fixes a bug when checking for a pdf-viewer. The patch also simplifies the check for the ps-viewer.

I also needed to change the checks for LaTeX and Ghostscript in my installer to fix bugs. I think that they must be included in your installer because they require huge code changes.

One problem is that MiKTeX's uninstaller doesn't delete the "Software\MiK\MiKTeX\CurrentVersion\MiKTeX" registry string when it is uninstalled. I check now for TeXLive and MiKTeX in the PATH. This also not easy because MiKTeX doesn't clean up the PATH when it is uninstalled so that a user could have three or more miktex-paths in the PATH. I also need to check for TeXLive in special registry entries because things have changed between TeXLive2004 or older and TeXLive2005. The current check in your installer works for 90% of all users. The rest can set the path to the latex.exe manually so we can leave it as it is.

Ghostscript does also not clean up the registry so that e.g. the entry for gs8.14 remains although gs8.50 is installed. I fixed this by cleaning up the registry while checking for gs. This means that I write to HKLM and need admin privileges. But as the user can always set the path manually we can also leave this as it is.

As you can see this is all very tricky and I sometimes need admin privileges to get a clean installation. The nasty registry stuff is also the reason that my installer don't run on Win98 because its registry system is different to Win2000/XP.

best regards Uwe
--- lyx_installer.nsi	Thu Dec 01 13:08:38 2005
+++ lyx_installer_UweChanges.nsi	Thu Dec 01 14:07:20 2005
@@ -113,7 +113,6 @@
 Var DownloadImageMagick
 
 Var PDFViewerPath
-Var PDFViewerProg
 
 Var PSViewerPath
 Var PSViewerProg
@@ -664,35 +663,33 @@
 
 ;--------------------------------
 
-; Sets the value of the global $PDFViewerPath and $PDFViewerProg variables.
+; Sets the value of the global $PDFViewerPath variable.
 Function SearchPDFViewer
+  ; test if a pdf-viewer is installed, only test for Acrobat, Adobe Reader (AroRD32), and GSview32
   StrCpy $PDFViewerPath ""
-  !insertmacro GetFileExtProg $PDFViewerPath $PDFViewerProg ".pdf" "a"
+  ReadRegStr $PDFViewerPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe" "Path"
+  ${if} $PDFVPath == ""
+   ReadRegStr $PDFViewerPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe" "Path"
+  ${endif}
+  ${if} $PDFVPath == ""
+   ReadRegStr $PDFViewerPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
+  ${endif}
+  StrCpy $0 $PDFViewerPath "" -1 ;remove the "\" at the end
+  ${if} $0 == "\"
+   StrCpy $PDFViewerPath $PDFViewerPath -1
+  ${endif}
 FunctionEnd
 
 ;--------------------------------
 
 Function SearchPSViewer
-  ; This function manipulates the $0 and $1 registers,
-  ; so push their current content onto the stack.
+  ; This function manipulates the $0 register,
+  ; so push its current content onto the stack.
   Push $0
-  Push $1
 
+  ; test if a ps-viewer is installed, only check for GSview32
   StrCpy $PSViewerPath ""
-  StrCpy $0 ""
-  StrCpy $1 ""
-  !insertmacro GetFileExtProg $PSViewerPath $PSViewerProg ".ps" "a"
-  ${if} $PSViewerPath != ""
-    StrCpy $0 $PSViewerPath
-    StrCpy $0 $0 "" -8
-  ${endif}
-  ${if} $0 == "Distillr"
-    !insertmacro GetFileExtProg $0 $1 ".ps" "b"
-    ${if} $1 != ""
-      StrCpy $PSViewerPath $0
-      StrCpy $PSViewerProg $1
-    ${endif}
-  ${endif}
+  ReadRegStr $PSViewerPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"
 
   ; Failed to find anything that way. Try another.
   ${if} $PSViewerPath == ""
@@ -709,8 +706,7 @@
     ${StrStrAdv} $PSViewerProg $PSViewerProg "\" "<" ">" "0" "0" "0"
   ${endif}
 
-  ; Return the $0 and $1 registers to their original states
-  Pop $1
+  ; Return the $0 register to its original states
   Pop $0
 FunctionEnd
 

Reply via email to