JAI wrote:
> Is there a way of automatically stopping and properly closing a
> Labview program (which is transparent to the user) without any prompts
> when the user shuts down their computer?
>
> Thanks!
In LabVIEW 6.1, there is an Event in the Event Structure called
"Application Exiting". This seems like it should be a fairly direct way
to do what you want. However, experimenting with it, it took me a while
to arrive at a solution.
I wrote a VI that has this event, along with a timeout event, in a
loop. If the "App Exiting" event fires, then another case structure
executes that calls the "Exit LabVIEW" function.
If you just use this event, then shut down windows, the event does
successfully fire, but one of two things happens. If the Discard option
is set to False, then after LabVIEW exits, Windows does not shut down,
as the event was discarded. If Discard is set to True, then you get a
LV dialog asking if all running VI's should be shut down. Regardless of
how you answer, Windows does not actually shut down! (This is using
W2K, SP2.)
Here is what I worked out. Set Discard to True. This eliminates
the pesky dialog that you don't want the operator seeing. Then, instead
of calling Exit LabVIEW, use the LVWinUtil library and call an exit
Windows function.
With this solution, I was able to write a program that would detect
when Windows was trying to shut down, it would then have a chance to do
whatever it needed to do to clean itself up, and then it would shut
Windows down itself.
Is this what you need? Let me know if you would like the VI.
It seems like this should be possible without using the LVWinUtil
library. If anybody knows what I am doing wrong and how to get this to
work using just the built-in LabVIEW functions and event structures,
please let me know.
Regards,
Dave
-------------------------------------------------------------
David Thomson 303-499-1973 (voice and fax)
Original Code Consulting dthomson@originalcode.com
www.originalcode.com
National Instruments Alliance Program Member
-------------------------------------------------------------
Research Scientist 303-497-3470 (voice)
NOAA Aeronomy Laboratory 303-497-5373 (fax)
Boulder, Colorado dthomson@al.noaa.gov
-------------------------------------------------------------