Re: Using ShellExecute




"Tom Backer Johnsen" <backer@xxxxxxxxxxxx> wrote in message
news:447fef7b@xxxxxxxxxxxxxxxxxxxxxxxxx
I am using ShellExecute to start a batch program, where the call on the
program contains filenames for the input (a set of commands) and the output
file. After the call, I want to process the output file. Evidently, my
program (written in D7) goes on with its own operations without waiting for
anything, with the result that the output file is empty right after the
call on ShellExecute. The operations in the batch program may vary in
respect to time, sometimes quite lengthy (actually, it is a statistical
system called R, very nice).

Now, is there some way of checking if the batch program is finished so I
can delay my program until the batch program is finished? Some API call
using the handle perhaps?

This is the C++ way of doing it - you may be able to work out the Delphi way
from this...

SHELLEXECUTEINFO ExecInfo;
memset (&ExecInfo, 0, sizeof(ExecInfo));
ExecInfo.cbSize = sizeof(ExecInfo);
ExecInfo.lpVerb = "open";
ExecInfo.lpFile = AppPath.c_str();
ExecInfo.lpParameters = Cmdline.c_str();
ExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ExecInfo.nShow = SW_SHOW;
bool RetCode = ShellExecuteEx(&ExecInfo);
WaitForSingleObject(ExecInfo.hProcess, INFINITE); // this waits
--
HTH Pete
=================================
www.frasersoft.net
GenHelp: "Making writing help fun"


.



Relevant Pages

  • Using ShellExecute
    ... I am using ShellExecute to start a batch program, where the call on the program contains filenames for the input (a set of commands) and the output file. ...
    (borland.public.delphi.non-technical)
  • Re: Using ShellExecute
    ... Pete Fraser wrote: ... program contains filenames for the input (a set of commands) and the output file. ... I want to process the output file. ...
    (borland.public.delphi.non-technical)
  • Re: Ahve got them Function Pointer blues
    ... struct FS ... My problem is that the <function pointer> is of unknown type - in ... and producing an output file. ... The commands will be, for example ...
    (comp.lang.c)
  • Re: Ahve got them Function Pointer blues
    ... and producing an output file. ... The commands will be, for example ... forth-like stack, with each stack element being a ... structure, which contains, among other things, a pointer to the function ...
    (comp.lang.c)
  • Re: Clone iMacs?
    ... and in unix, everything is a file. ... On 3/28/07, David Stubblebine wrote: ... I am just not sure about the commands. ...
    (Ubuntu)