
19.05.2008, 00:28
|
Прохожий
|
|
Регистрация: 15.06.2007
Сообщения: 14
Репутация: -7
|
|
Запуск файла после закрытия другого файла
Есть autorun-файл (install.exe). После нажатия Установить открывается setup-файл (setup.exe).
Надо, чтобы после завершения работы setup-файла открылся другой файл.
форма и таймер
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i:boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
ShellInfo: TShellExecuteInfo;
Code: DWord;
Hnd: THandle;
i:boolean;
begin
//i:=false;
//Application.ShowMainForm:=False
WinExec ('install.exe', SW_SHOW);
FillChar(ShellInfo, SizeOf(TShellExecuteInfo), 0);
ShellInfo.cbSize:=SizeOf(TShellExecuteInfo);
ShellInfo.fMask:=SEE_MASK_NOCLOSEPROCESS;
ShellInfo.Wnd:=HWND_DESKTOP;
ShellInfo.lpFile:='Disk\Setup.exe';
ShellInfo.lpParameters:=nil;
ShellInfo.lpDirectory:=nil;
ShellInfo.nShow:=SW_SHOWNORMAL;
//ShellExecuteEx(@ShellInfo); //Можно использовать вместо ShellExecute
Hnd:=ShellInfo.hProcess ;
GetExitCodeProcess(Hnd, Code);
if Code=Still_Active
then i:=true;
if (not (Code=Still_Active))and (i=true) then begin
WinExec('patch\mapatch.exe',SW_SHOW);
Application.Terminate end
{приложение работает};
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//if FindWindow('WinSupClass', 'Обозреватель')=0
if FindWindow('#36760', 'InstallShield Wizard')<>0
then
i:=true;
//if FindWindow('#36760', 'InstallShield Wizard')=0
//then
else
if i=true then
begin
WinExec('patch\mapatch.exe',SW_SHOW);
Application.Terminate
end
end;
end.
|