05-10-2010 03:00 PM
05-10-2010 03:22 PM
There is no good way to directly kill another executable in Windows. When you terminate another proces like you're doing (I'm pretty sure the CVI library call results in a TerminateProcess Win32 API call) it is terminated after any pending I/O is completed or cancelled, then shuts down all threads immediately. The OS can eventually clean up any process resources but DLL's don't get notified and can get left hanging.
The official Microsoft view is that you should send a message to the application to tell it to terminate itself with ExitProcess API function so that a "good" termination takes place.
You can hook into the CVI main panel's native windows message callbacks using a CVI library function, RegisterWinMsgCallback, then use PostMessage in the Win32 API to send the terminate message to your child CVI application.
Or, in your case, if your "Visual C" (Visual C++?) application processes the terminate message, it should then do an orderly termination. In lieu of terminating the child process, send it a terminate message using PostMessage. If you wrote the child process, you can make sure it handles the terminate message and executes the code you want.
05-10-2010 03:29 PM
Thanks Menchar,
We have already started planning to to setup an event message to the external app for it to close itself down properly. I was just hoping there was an easier way.