How can I tell if the system is being shutdown/restarted as at the moment my program blocks any kind of shutdown/restart unless you close it manually, so I need to tell it to close when this event occurs
Cheers
Tim
Printable View
How can I tell if the system is being shutdown/restarted as at the moment my program blocks any kind of shutdown/restart unless you close it manually, so I need to tell it to close when this event occurs
Cheers
Tim
You can use SystemEvents.SessionEnding, but I haven't figured out how you actually use it yet.. Have you?
Its very easy to use. You add an event handler just like any event
VB Code:
Sub main() addhandler Microsoft.Win32.SystemEvents.SessionEnding, addressof Shutdown End Sub Sub Shutdown (sender as Object, e as Microsoft.Win32.SessionEndingEventArgs) 'add any shutdown code here Application.Exit() End Sub