Well, this has turned out to be more difficult than I imagined. Here's
a little more information which I gather will just make things harder:
I'm using Windows 2000.
If a program is already running, chances are good that my Vee
application didn't start it originally - it was probably done by the
computer operator using a shortcut on the desktop.
The programs in question were probably not written by me and I have no
advanced knowledge concerning what they are likely to be.
Barrie
---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
a little more information which I gather will just make things harder:
I'm using Windows 2000.
If a program is already running, chances are good that my Vee
application didn't start it originally - it was probably done by the
computer operator using a shortcut on the desktop.
The programs in question were probably not written by me and I have no
advanced knowledge concerning what they are likely to be.
Barrie
---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
> my Vee application didn't start it originally - it was
> probably done by the computer operator using a shortcut
> on the desktop.
<Stan Marsh>Holy **** Dude!</Stan Marsh>
In that case, here's the ****. I'm assuming this is for disaster recovery.
1. In VEE, use CreateProcess to start applications. Record the PID in a
file.
2. At the beginning of your app, use OpenProcess on all the recorded PIDs.
If it succeeds, use WaitForSingleObject on the process handle with a wait
time of 0. If the process is still running it will return WAIT_OBJECT_0. If
it is not, it will return WAIT_TIMEOUT. If it returns WAIT_ABANDONED then
VEE previously crashed or was exited in some way without a proper shutdown.
Proper shutdown means that the VEE process causes the child process to
terminate normally. The use of TerminateProcess *is* considered proper
termination. The thing is that it's the VEE process that started the child
process that must cause the child to terminate. Upon proper termination of a
process, delete it's PID from the list.
If OpenProcess doesn't succeed, then the process has terminated and should
be restarted (or whatever it is you need to do in that case). The PID should
be deleted from the list.
This is a situation that can cause unsuspected resource leaks. After using
CreateProcess, you MUST call CloseHandle on the returned handles. These are
the Thread and Process handles returned by the CreateProcess call in the
PROCESS_INFORMATION structure. It's not that big a deal on NT, but on 9x
ignoring CloseHandle can run you out of resources after thousands of start
up/shutdown cycles. Even on NT it can be shocking to see the VEE process in
ownership of thousands of abandoned process and thread objects.
-SHAWN-
---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".