>I need to launch a small VFP 6.0 exe from within my main VFP exe to run as a sperate running windows exe. That part is simple and I have done it.
>
>The hard part is when the main app shuts down I would like to be able to have the 2nd exe shut down. I know I have the 2nd exe check every so often for whatever but if the user is shutting down his PC then it would probibly not check soon enough without eating up a lot of processing power constantly.
>
>Is there a direct way? Or do I just check for a flag in a table every 10 seconds with the 2nd exe.
You could set something up to use PostMessage() to send a WM_QUIT, or use the WSH Wscript.Shell's AppActivate and SendKeys methods to send something to the other app forcing shutdown through an OKL or something similar. If you launch the second app using API_APPRUN, you can modify it to snag the thread handle and use PostThreadMessage() to send a WM_CLOSE or WM_QUIT to the second app's message queue; I've placed an entry in the WinAPI section showing the declaration for PostThreadMessage(), and API_APPRUN is released with source, so you could modify it as you'd like. I do not have source to give you to do this; I have done similar things for use for my clients with good results.