I start an utility exe with ShellExecute(...) from my code
and I'd like to wait until that exe completed.
How can I do that?
Diggin in the win32 help, I found ShellExecuteEx that returns the
handle of the instance created. There's also WaitForSingleObject(handle, timeout)
But how can I combine these?
Should I look for the process associated with the instance? and how would that work?
Thanks in advance,
Gerrit Beuze
A process handle becomes signaled when the process terminated.
WaitForSingleObject returns when the specified object becomes signaled
or the timeout elapses. If ShellExecuteEx executed (and indeed returned
a valid process handle - not an error) you can call
WaitForSingleObject(ReturnedHandle, INFINITE);
to wait until the process is terminated.
I understand the WaitForSigleObject bit, but how do I get the process handle?
Gerrit
"Avatar Zondertau" <avatarz...@hotmail.com> wrote in message news:412ce004$1...@newsgroups.borland.com...
The hProcess member of the SHELLEXECUTEINFO structure passed to
ShellExecuteEx should contain it after the call if the proper flags are
set (set fMask to SEE_MASK_NOCLOSEPROCESS).
Thanks,
Gerrit
"Avatar Zondertau" <avatarz...@hotmail.com> wrote in message news:412ce35b$1...@newsgroups.borland.com...
You are on the right track. The rest of the puzzle you'll find here:
(one line)
Another possibility is CreateProcess(), but ShellExecuteEx() is somewhat
simpler to use and ok in most cases.
JensG