Board index » delphi » Winexec - wait in DELPHI 2.0

Winexec - wait in DELPHI 2.0

I wish to call a Dos command ie PKZIP to unzip a file, wait until it is
completed then go to next statement to open the file for viewing.  How
can I use the Winexec wait in Delphi 2.0.  I know it can be done in
Delphi 1.0

Thanx...Liz

 

Re:Winexec - wait in DELPHI 2.0


If you use WinZIP or another Win Apps then try my Delphi 2 component
TAppProp!
http://www.nethosting.com/~vit/index.html
Regards!
Vit

Elizabeth Poy <liz...@wr.com.au> wrote in article
<32842E49.6...@wr.com.au>...
: I wish to call a Dos command ie PKZIP to unzip a file, wait until it is
: completed then go to next statement to open the file for viewing.  How
: can I use the Winexec wait in Delphi 2.0.  I know it can be done in
: Delphi 1.0
:
: Thanx...Liz
:

Re:Winexec - wait in DELPHI 2.0


May be something like  this will be useful :
 for i:=1 to 1000 do Application.ProcessMessages ;
Regards
Svetlana

Re:Winexec - wait in DELPHI 2.0


Quote
lgamt...@aol.com wrote:
> May be something like  this will be useful :
>  for i:=1 to 1000 do Application.ProcessMessages ;

Actually, what you should do is to start the application using
CreateProcess, and the use WaitForSingleObject on the process ID returned by
Create Process.  The process will signal when the application terminates.

oversimplified pseudo-code:

BEGIN
  pid:=CreateProcess(ApplicationToRun);
  WaitForSingleObject(pid);
  ShowDialog('Application is done');
END;

Lars F.

--
/Mr.Lars Fosdal    /Falcon AS   (a REUTERS company)   /Tel.+47 22005734
/lfos...@falcon.no /Stortorvet 10, N0155 OSLO, Norway /Fax.+47 22005777

Re:Winexec - wait in DELPHI 2.0


Oversimplified pseudo code was given.  Here's the real thing:

  Success := CreateProcess(nil,PathnameOfFileToRun,
  Nil,Nil,False,NORMAL_PRIORITY_CLASS,
    nil,WorkDir,TSI,TPI);

  repeat
    Application.ProcessMessages;
  until (WaitForSingleObject(TPI.hProcess,100) =
    WAIT_OBJECT_0) or (Application.Terminated);

The inherent simplification in this is I didn't really tell you how to
use CreateProcess.  Hopefully you already know how to do that,but just
in case, TSI and TPI are structures.  Look up the CreateProcess help
file.

Good luck!

Chris

Quote
Lars Fosdal wrote:

> lgamt...@aol.com wrote:

> > May be something like  this will be useful :
> >  for i:=1 to 1000 do Application.ProcessMessages ;

> Actually, what you should do is to start the application using
> CreateProcess, and the use WaitForSingleObject on the process ID returned by
> Create Process.  The process will signal when the application terminates.

> oversimplified pseudo-code:

> BEGIN
>   pid:=CreateProcess(ApplicationToRun);
>   WaitForSingleObject(pid);
>   ShowDialog('Application is done');
> END;

> Lars F.

> --
> /Mr.Lars Fosdal    /Falcon AS   (a REUTERS company)   /Tel.+47 22005734
> /lfos...@falcon.no /Stortorvet 10, N0155 OSLO, Norway /Fax.+47 22005777

Other Threads