Haha, no problem :)

Chris

> -----Original Message-----
> From: vss [mailto:vss@;vss.co.nz]
> Sent: Monday, 11 November 2002 4:41 p.m.
> To: Multiple recipients of list delphi
> Subject: RE: RE: [DUG]: Execute and wait
> 
> 
> sorry chris I take that back...it does...I should have just 
> pressed teh 
> right button :)
> 
> Jeremy
> 
> -----Original Message-----
> From: "Chris Milham" <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Date: Mon, 11 Nov 2002 15:59:07 +1300
> Subject: RE:  RE: [DUG]:  Execute and wait
> 
> > Hmm.. I don't know where those "3D"s came from :/
> > Just remove them all and you should be fine. Make sure you are using
> > the =
> > windows unit.
> > 
> > Chris
> > 
> > > -----Original Message-----
> > > From: vss [mailto:vss@;vss.co.nz]
> > > Sent: Monday, 11 November 2002 3:44 p.m.
> > > To: Multiple recipients of list delphi
> > > Subject: RE: [DUG]: Execute and wait
> > >=20
> > >=20
> > > Hi Chris. I tried your code, but it failed here
> > >=20
> > > cb :=3D3D SizeOf(TStartupInfo);
> > >=20
> > > Jeremy
> > >=20
> > > -----Original Message-----
> > > From: "Chris Milham" <[EMAIL PROTECTED]>
> > > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > > Date: Mon, 11 Nov 2002 15:13:44 +1300
> > > Subject: RE: [DUG]:  Execute and wait
> > >=20
> > > > Try this one. I have just wrapped a version of=20
> > > "WinExecAndWait32". This
> > > > =3D
> > > > one DEFINITELY waits correctly.
> > > > HTH
> > > >=20
> > > > Chris
> > > >=20
> > > > procedure ExecuteProgram(sPath: string; bWait: Boolean);
> > > >   function WinExecAndWait32(Path: PChar; Visibility: Word;
> > > >     Timeout: DWORD): integer;
> > > >   var
> > > >     WaitResult: integer;
> > > >     StartupInfo: TStartupInfo;
> > > >     ProcessInfo: TProcessInformation;
> > > >   begin
> > > >     FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
> > > >     with StartupInfo do
> > > >     begin
> > > >       cb :=3D3D SizeOf(TStartupInfo);
> > > >       dwFlags :=3D3D STARTF_USESHOWWINDOW or
> > STARTF_FORCEONFEEDBACK;
> > > >     { you could pass sw_show or sw_hide as parameter: }
> > > >       wShowWindow :=3D3D visibility;
> > > >     end;
> > > >     if CreateProcess(nil, path, nil, nil, False,
> > > >       NORMAL_PRIORITY_CLASS, nil, nil,
> > > >       StartupInfo, ProcessInfo) then
> > > >     begin
> > > >       WaitResult :=3D3D 
> WaitForSingleObject(ProcessInfo.hProcess, =
> > =3D
> > > > timeout);
> > > >       { timeout is in miliseconds or INFINITE if
> > > >       you want to wait forever }
> > > >       result :=3D3D WaitResult;
> > > >     end
> > > >     else
> > > >     { error occurs during CreateProcess see help for details }
> > > >       result :=3D3D GetLastError;
> > > >   end;
> > > > begin
> > > >   SetCurrentDir(ExtractFilePath(Application.ExeName)); {Set=20
> > > this so =3D
> > > > relative paths will work}
> > > >   if not FileExists(sPath) then begin
> > > >     DlgError('Unable to run "' + sPath + '"'+NL+'The=20
> > > program cannot be
> > > > =3D
> > > > found.');
> > > >   end else begin
> > > >     if bWait then begin
> > > >       WinExecAndWait32(PChar(sPath), SW_SHOW, INFINITE);
> > > >     end else begin
> > > >       WinExecAndWait32(PChar(sPath), SW_SHOW, 0);
> > > >     end;
> > > >   end;
> > > > end;
> > > >=20
> > > >=20
> > > >=20
> > > > > -----Original Message-----
> > > > > From: vss [mailto:vss@;vss.co.nz]
> > > > > Sent: Monday, 11 November 2002 3:08 p.m.
> > > > > To: Multiple recipients of list delphi
> > > > > Subject: [DUG]: Execute and wait
> > > > >=3D20
> > > > >=3D20
> > > > > Hi All.
> > > > > I have a bit of code that does an execute and waits 
> for the app.
> > > > to=3D20
> > > > > close.
> > > > > What I want to do is execute a game and know when its=3D20
> > > > > finished, BUT when=3D20
> > > > > I use my code, it starts to execute the app, but then it=20
> > > stops and=3D20
> > > > > returns an error code of zero which means its 
> finished...BUT it
> > > > never=3D20
> > > > > started.
> > > > > This is teh code I use. anyone got anything better?
> > > > >=3D20
> > > > > Jeremy
> > > > >=3D20
> > > > >=3D20
> > > > > function TfrmMain.WinExecAndWait32(Path: PChar;=20
> > > Visibility: Word):=3D20
> > > > > integer;
> > > > > var Msg: TMsg;
> > > > >     lpExitCode: cardinal;
> > > > >     StartupInfo: TStartupInfo;
> > > > >     ProcessInfo: TProcessInformation;
> > > > > begin
> > > > >   FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
> > > > >   with StartupInfo do
> > > > >   begin
> > > > >     cb :=3D3D SizeOf(TStartupInfo);
> > > > >     dwFlags :=3D3D STARTF_USESHOWWINDOW or
> > STARTF_FORCEONFEEDBACK;
> > > > >     wShowWindow :=3D3D visibility; {you could pass sw_show=20
> > > or sw_hide
> > > > as =3D
> > > >=20
> > > > > parameter}
> > > > >   end;
> > > > >=3D20
> > > > >   if CreateProcess(nil, path, nil, nil, False,
> > > > NORMAL_PRIORITY_CLASS,=3D20
> > > > > nil, nil, StartupInfo,
> > > > >                    ProcessInfo) then
> > > > >   begin
> > > > >     repeat
> > > > >       while PeekMessage(Msg, 0, 0, 0, pm_Remove) do
> > > > >       begin
> > > > >         if Msg.Message =3D3D wm_Quit then Halt(Msg.WParam);
> > > > >         TranslateMessage(Msg);
> > > > >         DispatchMessage(Msg);
> > > > >       end;
> > > > >       GetExitCodeProcess(ProcessInfo.hProcess,lpExitCode);
> > > > >     until lpExitCode <> Still_Active;
> > > > >=3D20
> > > > >     with ProcessInfo do {not sure this is necessary 
> but seen=3D20
> > > > > in in some=3D20
> > > > > code elsewhere}
> > > > >     begin
> > > > >       CloseHandle(hThread);
> > > > >       CloseHandle(hProcess);
> > > > >     end;
> > > > >     Result :=3D3D 0; {success}
> > > > >   end else Result :=3D3D GetLastError;
> > > > > end;
> > > > >=3D20
> > > > > --------------------------------------------------------------
> > > > > -------------
> > > > >     New Zealand Delphi Users group - Delphi List -=3D20
> > > > > [EMAIL PROTECTED]
> > > > >                   Website: http://www.delphi.org.nz
> > > > > To UnSub, send email to: [EMAIL PROTECTED]=3D20
> > > > > with body of "unsubscribe delphi"
> > > > > Web Archive at:=20
> > > http://www.mail-archive.com/delphi%40delphi.org.nz/
> > > > >=3D20
> > > >=20
> > > --------------------------------------------------------------
> > > ---------
> > > > ----
> > > >     New Zealand Delphi Users group - Delphi List -=20
> > > [EMAIL PROTECTED]
> > > >                   Website: http://www.delphi.org.nz
> > > > To UnSub, send email to: [EMAIL PROTECTED]=20
> > > > with body of "unsubscribe delphi"
> > > > Web Archive at: 
> http://www.mail-archive.com/delphi%40delphi.org.nz/
> > >=20
> > > --------------------------------------------------------------
> > > -------------
> > >     New Zealand Delphi Users group - Delphi List -=20
> > > [EMAIL PROTECTED]
> > >                   Website: http://www.delphi.org.nz
> > > To UnSub, send email to: [EMAIL PROTECTED]=20
> > > with body of "unsubscribe delphi"
> > > Web Archive at: 
> http://www.mail-archive.com/delphi%40delphi.org.nz/
> > >=20
> > 
> --------------------------------------------------------------
> ---------
> > ----
> >     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED] 
> > with body of "unsubscribe delphi"
> > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to