Re: Using ShellExecute
- From: "Pete Fraser" <pete.nospam.fraser.nospam@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 2 Jun 2006 09:18:00 +0100
"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"
.
- Follow-Ups:
- Re: Using ShellExecute
- From: Tom Backer Johnsen
- Re: Using ShellExecute
- References:
- Using ShellExecute
- From: Tom Backer Johnsen
- Using ShellExecute
- Prev by Date: Re: Generics + D2007/win32
- Next by Date: Re: Generics + D2007/win32
- Previous by thread: Using ShellExecute
- Next by thread: Re: Using ShellExecute
- Index(es):
Relevant Pages
|
|