hi,
This can be done by managing the windows process.
attached is the code how to do it.
create a process
in a timer check whether the process is active, if not
close the parent form.
hope this helps
Manoj.
***************************************************
unit uFirst;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, StdCtrls, uCommon, shellapi, ExtCtrls;
type
TfrmFirst = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
procedure MyMethod;
public
{ Public declarations }
end;
var
frmFirst: TfrmFirst;
ProcInfo : TProcessInformation;
StartInfo : TStartupInfo;
ExitCode: LongWord;
implementation
{$R *.dfm}
{ TfrmFirst }
procedure ExecNewProcess(ProgramName : String);
var
CreateOK : Boolean;
Prid : Integer;
begin
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
CreateOK := CreateProcess(PChar(ProgramName),nil,
nil, nil,False,
CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
nil, nil, StartInfo, ProcInfo);
if CreateOk then
frmFirst.Timer1.Enabled := True;
end;
procedure TfrmFirst.Button1Click(Sender: TObject);
begin
ExecNewProcess('prjSecond.exe');
end;
procedure TfrmFirst.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if GetExitCodeProcess(Procinfo.hProcess, ExitCode)
then
begin
if ExitCode = STILL_ACTIVE then
Timer1.Enabled := True
else
MyMethod;
end;
end;
procedure TfrmFirst.MyMethod;
begin
Close;
end;
end.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/