catch message from closing console application

Hello,

I have a console application that I start from my GUI application as follows:

WinExec(page->m_PlatingMasterConsoleExe.c_str(), SW_SHOW);

The idea is to catch a message when I close the console window before it finishes (e.g. forced finish of application by user who do not wants to wait until the console reaches its end).

Is there a way to catch messages from a console application.
Any code samples are higly appreciated.

Bob
[486 byte] By [bobfromb] at [2007-11-18 22:15:11]
# 1 Re: catch message from closing console application
Don't use 'WinExec', use 'CreateProcess' instead. Then, you can use the handle to the created process to monitor it. I believe if you do a "WaitForSingleObject" on the created proc's handle, when the wait is triggered, the process has ended (but I could be wrong; it's been a while since I played with that).

Viggy
MrViggy at 2007-11-9 12:03:17 >
# 2 Re: catch message from closing console application
'WinExec()' is only provided for compatibility with 16-bit Windows and should not be used any longer...take a look at the following two FAQs which answer your questions...

How can I start a process? (http://www.dev-archive.com/forum/showthread.php?t=302501)
How can I wait until a process ends ? (http://www.dev-archive.com/forum/showthread.php?s=&threadid=231238)
Andreas Masur at 2007-11-9 12:04:21 >