]> git.lyx.org Git - features.git/commitdiff
installer: better version for the launcher
authorUwe Stöhr <uwestoehr@web.de>
Sun, 20 May 2007 14:06:34 +0000 (14:06 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sun, 20 May 2007 14:06:34 +0000 (14:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18431 a592a061-630c-0410-9148-cb99ea01b6c8

development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dof
development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dpr
development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe

index 6d6616bd815a6e5570a0c6d1e3ddeede2d4f31b7..1dfc1470b6c5f1ca58605972218bb672e91ad66e 100644 (file)
@@ -95,7 +95,7 @@ UnitOutputDir=
 PackageDLLOutputDir=
 PackageDCPOutputDir=
 SearchPath=
-Packages=vcl;rtl;vclx;indy;vclie;xmlrtl;inetdbbde;inet;inetdbxpress;dbrtl;soaprtl;dsnap;VclSmp;dbexpress;vcldb;dbxcds;inetdb;bdertl;vcldbx;adortl;teeui;teedb;tee;ibxpress;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL
+Packages=vcl;rtl;vclx;dbrtl;vcldb;bdertl;vclshlctrls;vclactnband;adortl;vcldbx;VclSmp;visualclx;visualdbclx;dbexpress;vclie;xmlrtl;inetdbbde;inet;inetdbxpress;teeui;teedb;tee;Rave50CLX;Rave50VCL;IntrawebDB_50_70;Intraweb_50_70;indy;ibxpress;dsnap;soaprtl;dbxcds;inetdb
 Conditionals=
 DebugSourceDirs=
 UsePackages=0
index 08317f720b37db308223da8ec593a20a72b65ecf..f91d1b91cd525c27275f391b92fc3a847b7f01fe 100644 (file)
@@ -10,121 +10,89 @@ program lyxLauncher;
 {$APPTYPE CONSOLE}
 
 uses
-  Windows, SysUtils, ShellApi, Forms, Dialogs;
+  Windows, SysUtils, ShellApi, Dialogs;
 
-var Path : string;
+var Path,FileName : string;
+    hConsole : THandle;
+
+
+procedure StartLyX(hConsole: THandle; FileName,Path: string);
+// starts LyX
+
+var Params : PChar;
     hLyX : THandle;
+begin
+
+ // if a filename is given, convert it to a PChar; needed for the ShellExecute
+ if FileName <> '' then
+  Params:= PChar(FileName)
+ else
+  Params:= nil;
+
+ // start LyX
+ hLyX:= ShellExecute(hConsole,PChar('open'),
+                     PChar(Path),Params,nil,SW_SHOWNORMAL);
+ if hLyX = ERROR_FILE_NOT_FOUND  then
+ begin
+  MessageDLG('The file'#13#10 + Path + #13#10
+             + 'could not be found!',mtError,[mbOK],0);
+  exit;
+ end;
+ if hLyX = SE_ERR_ACCESSDENIED  then
+ begin
+  MessageDLG('Windows denied access on the file'#13#10 + Path,
+             mtError,[mbOK],0);
+  exit;
+ end;
+
+end; // end procedure
+
 
 procedure HideWindow(ProgWin: string);
 // hides a given program window
-var
-  Handle : THandle;
+
+var Handle : THandle;
 begin
 
  // find handle of the program window
  // Repeat until the handle is available
  // because Lyx needs some time to start
  Repeat
+  Sleep(1000); // wait 1 second to give LyX time to open
   Handle := FindWindow(nil,Pchar(ProgWin));
  Until Handle <> 0;
- // minimize the window
- // SendMessage(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 1);
+
  // hide the window from taskbar
  ShowWindow(Handle, SW_HIDE);
 
 end; //end procedure
 
-procedure ReadPath(FileName: string; LaunchName: string;
-                   ExecName: string; var PathR: string);
-// reads the path to the lyx.exe from a given text file
-var InString : string;
-    FileSize,Index,Last : Int64;
-    hFile : THandle;
-    PInString : PChar;
-
-begin
 
- try //try..except for procedure
-  // open the text file
-  hFile:= Windows.CreateFile(PChar(FileName),GENERIC_READ,0,nil,
-                            OPEN_EXISTING,
-                            FILE_FLAG_SEQUENTIAL_SCAN,0);
-  if hFile= INVALID_HANDLE_VALUE then
-  begin
-   MessageDlg('The file "' + FileName + '" could not be found!',
-               mtError,[mbOK],0);
-   exit;
-  end;
-  
-  try //try..finally for hFile
-   FileSize:= FileSeek(hFile,0,2); //get file size
-   if FileSize = -1 then
-    RaiseLastOSError;
-
-   //move file content to InString
-   FileSeek(hFile,0,0);
-   SetLength(InString,FileSize);
-   PInString:= PChar(InString);
-   FileRead(hFile,PInString^,FileSize);
-
-   //search the string backwards for the first appearance of ":"
-   Index:= FileSize;
-   Repeat
-    dec(Index);
-    if InString[Index] = ':' then
-     Break;
-   Until (InString[Index] = #10) or (Index = 1);
-
-   //if the last line of lyx.bat doesn't contain a ":" (a path)
-   if (InString[Index] = #10) or (Index = 1) then
-   begin
-    MessageDlg('The file lyx.bat is corrupted!',mtError,[mbOK],0);
-    exit;
-   end;
-
-   //jump before the ":" to the drive letter
-   dec(Index);
-   //search for the LaunchName = end of the path
-   Last:= Pos(LaunchName,InString);
-   //the InString contains between Index and Last the wanted path
-   PathR:= Copy(InString,Index,Last - Index);
-   //attach LyX's executable to the path
-   PathR:= Path + ExecName;
-
-  finally //close the text file
-   Windows.CloseHandle(hFile);
-  end; //end finally
-
- except //when an error occurred somewhere in the procedure
-  MessageDlg('The file "' + FileName + '" is corrupted!',mtError,[mbOK],0);
- end; //end except
+begin //begin program
 
-end; //end procedure
+ //Read path to this application
+ Path:= ParamStr(0);
 
+ //get handle of this console window
+ // This application is called by the lyx.bat with the name "LyX"
+ hConsole := FindWindow(nil,Pchar('LyX'));
+ // hide the window of this console application
+ ShowWindow(hConsole,SW_HIDE);
 
-begin //begin program
+ // do the same for the real name of this console application
+ // because it depends on the computer speed if the "LyX" console window
+ // was closed before it could be processed
+ hConsole := FindWindow(nil,Pchar(Path));
+ ShowWindow(hConsole,SW_HIDE);
 
- //hide the window of this application
ShowWindow(Application.Handle,SW_HIDE);
+ // replace in the path "lyxLauncher.exe" by "lyx.exe"
Path:= StringReplace(Path, 'lyxLauncher', 'lyx', [rfIgnoreCase]);
 
- // read path of the lyxLauncher.exe from the file lyx.bat 
ReadPath('lyx.bat', 'lyxLauncher.exe', 'lyx.exe', Path);
+ // read given filename of a LyX-document
FileName:= ParamStr(1);
 
  // start LyX
- hLyX:= ShellExecute(Application.Handle,PChar('open'),
-                     PChar(Path),nil,nil,SW_SHOWNORMAL);
- if hLyX = ERROR_FILE_NOT_FOUND  then
- begin
-  MessageDLG('The file'#13#10 + Path + #13#10
-             + 'could not be found!',mtError,[mbOK],0);
-  exit;
- end;
- if hLyX = SE_ERR_ACCESSDENIED  then
- begin
-  MessageDLG('Windows denied access on the file'#13#10 + Path,
-             mtError,[mbOK],0);
-  exit;
- end;
+ StartLyX(hConsole,FileName,Path);
 
  // hide console window of lyx.exe
  HideWindow(Path);
index 16e314fb2bc529ce7805180a5451a6b3f685193f..e4951620b57aeeca0ffcac3fa025a68f66586bef 100644 (file)
Binary files a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe and b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe differ