02-10-2011 05:18 AM
I wish that my Labview program at shutdown the OS cleanly shut down before shutting down the OS. I would like to know in Labview was triggered when the end to save all settings.
Can someone tell me how and where can I check on the shutdown in Labview.
Thanks
02-10-2011 06:54 AM
I think that you will not need an additional DLL for this.
Shutting down the OS programmatically is always done by the OS API. In case of Windows, it would be the Shutdown command.
If you open the link above, you will see that you can pass parameter to this command. One will delay the shutdown routine for the specified time (in seconds). This should leave enough time to close LV properly by using the Quit LabVIEW function.
But note: i never tested if the OS' shutdown is canceled if the process, which initated this shutdown, is closed before the shutdown takes place....
hope this helps,
Norbert
02-10-2011 10:48 AM - edited 02-10-2011 10:49 AM
As far as I remember, you have to set AutoEndTask key in HKCU\Control Panel\Desktop to 1.
You may also adjust registry keys HungAppTimeout and WaitToKillAppTimeout to other than default values (depends how long you need for saving data, etc)
Then in Top Level VI you should add case "Application Instance Close?" into Event Structure.
Now, when Windows will initiate shutting down process, then this event will be triggered (you can discard it, then save data, and then finally call LabVIEW Exit for "normal" termination.
This way worked for me.
Otherwise I haven't tried to cancel shutdown (and don't recommend to do it, because partially Windows already shutted down - some services may be already stopped, etc). If you need to really cancel shutdown from your application, then your application should be the first in "shutdown sequence" - here you need deep knowledge about WinAPI. But impossible is nothing.
2Norbert: as far as I know, msdos shutdown command will work only with administrative privileges.
Andrey.
02-16-2011 02:50 PM