I would use a semiphore file to signal the other app to close. I would use a timer in the Application object which would check for the presence of this file and when "seen" would gracefully shut down itself.
The exe which spawns this external exe when shutting down should place the token file in a "visible" directory.
Glenn
>My main application starts a second exe that remains running all the time.
>When the main application closes, the secondary exe should close automatically. Is there an elegant way to do this?
>
>
>I have used Ed Rauh class (File #
9477) to launch the secondary FoxPro exe. It can be closed with his KillProc(), which runs TerminateProcess. That works, but Ed had a note in his class that says this does not shut down in an orderly fashion; it should only be used for emergencies!
>
>So the question is: how does one close the secondary exe in an orderly fashion?
>
>Cyril