Project___2007___QuickLaunch.7z 22.89KB 531 downloads
Here is the batch file:
if exist B:\Avast4\Data\dl.exe goto run start /min /wait avastav.exe x -y -oB:\Avast4\ ::primer start B:\Avast4\ashSimp.exe :run start /min /wait B:\Avast4\Data\dl.exe http://download4.avast.com/files/latest/400.vps /output:B:\Avast4\Data\400.vps /update start B:\Avast4\ashSimp.exe exit
And the respective delphi source code:
program QuickLaunch; //{$APPTYPE CONSOLE} - this way we make this app invisible.. uses ShellApi, Windows, SysUtils; var Handle : THandle; i : Integer; Parameters : String; Procedure ShellExecAndWait(Filename, Parameters, Action : String); // this procedure will run an application and will only continue after // if finishes - just like "start /wait myApp.exe" Var exInfo: TShellExecuteInfo; exitcode: DWORD; aAction : String; Begin FillChar( exInfo, Sizeof(exInfo), 0 ); With exInfo Do Begin cbSize:= Sizeof( exInfo ); // required! fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT; Wnd := Handle; // forms handle lpFile:= Pchar( Filename ); lpParameters:= Pchar( Parameters ); aAction:=LowerCase(Action); if aAction = 'hide' then nShow := SW_HIDE else if aAction = 'minimize'then nShow := SW_MINIMIZE else nShow := SW_SHOWNORMAL; lpVerb := 'open'; End; If ShellExecuteEx( @exInfo ) Then Begin While GetExitCodeProcess( exinfo.hProcess, exitcode ) and (exitcode = STILL_ACTIVE) // loop while process is active.. Do begin sleep(100); end; CloseHandle( exinfo.hProcess ); End; end; // shellexecute and wait Label primer, run; begin // If you have at least one parameter - run it in hidden mode (like cmdow) if paramCount > 1 then begin for i:=2 to paramcount do parameters := parameters + paramStr(i); ShellExecute(Handle, 'open', pChar(paramStr(1)), Pchar(parameters), '', SW_HIDE); // run hidden exit; end; // Otherwise let's do the quicklaunch imitating the following batch file code: { if exist B:\Avast4\Data\dl.exe goto run start /min /wait avastav.exe x -y -oB:\Avast4\ ::primer start B:\Avast4\ashSimp.exe :run start /min /wait B:\Avast4\Data\dl.exe http://download4.avast.com/files/latest/400.vps /output:B:\Avast4\Data\400.vps /update start B:\Avast4\ashSimp.exe exit } If FileExists('B:\Avast4\Data\dl.exe')then goto run; ShellExecAndWait('avastav.exe','x -y -oB:\Avast4\', 'minimize'); primer: ShellExecute(Handle, 'open', pChar('B:\Avast4\ashSimp.exe'), PChar(''), '', SW_MINIMIZE); run: ShellExecAndWait('B:\Avast4\Data\dl.exe','http://download4.avast.com/files/latest/400.vps /output:B:\Avast4\Data\400.vps /update','minimize'); { The above code will mimic the batch file, but it can also be replaced this way to be more efficient: If FileExists('B:\Avast4\Data\dl.exe') then ShellExecAndWait('B:\Avast4\Data\dl.exe','http://download4.avast.com/files/latest/400.vps /output:B:\Avast4\Data\400.vps /update','minimize') else begin ShellExecAndWait('avastav.exe','x -y -oB:\Avast4\', 'minimize'); ShellExecute(Handle, 'open', pChar('B:\Avast4\ashSimp.exe'), PChar(''), '', SW_MINIMIZE); end; } end. { Usefull info about shellexecute Value Meaning SW_HIDE Hides the window and activates another window. SW_MAXIMIZE Maximizes the specified window. SW_MINIMIZE Minimizes the specified window and activates the next top-level window in the Z order. SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window. SW_SHOW Activates the window and displays it in its current size and position. SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window. SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window. SW_SHOWMINIMIZED Activates the window and displays it as a minimized window. SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window remains active. SW_SHOWNA Displays the window in its current state. The active window remains active. SW_SHOWNOACTIVATE Displays a window in its most recent size and position. The active window remains active. SW_SHOWNORMAL Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time. }
This code was based on a previous app found here:
http://www.911cd.net...&...st&p=113007
This app also doubles as a way to launch programs in hidden mode, just add any other program as parameter and it will be executed.
Hope this helps!