From: Uwe Stöhr Date: Sun, 20 May 2007 14:06:34 +0000 (+0000) Subject: installer: better version for the launcher X-Git-Tag: 1.6.10~9685 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=edd14e93f9b41239923bacf575a0e8d1e7ff5ad0;p=features.git installer: better version for the launcher git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18431 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dof b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dof index 6d6616bd81..1dfc1470b6 100644 --- a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dof +++ b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dof @@ -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 diff --git a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dpr b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dpr index 08317f720b..f91d1b91cd 100644 --- a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dpr +++ b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.dpr @@ -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); diff --git a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe index 16e314fb2b..e4951620b5 100644 Binary files a/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe and b/development/Win32/packaging/AltInstaller/specials/Launcher/lyxLauncher.exe differ