system shut down event for a vb prog ?

I had a vb prog continuous running in the background, when the system shut down, how can I know this event, and response to it ( e.g. a message, or prevent it to shut down ) ?
Thanks
stanleylcmAsked:
Who is Participating?
 
stefanxConnect With a Mentor Commented:
On any form, capture the Form_QueryUnload event. This gets passed two parameters :

Cancel (ByRef)
UnloadMode

If UnloadMode = 2 then the closing of the window is occurring because Windows is shutting down. To prevent it, set Cancel to any non-zero value and exit the sub.

0
 
stanleylcmAuthor Commented:
Thanks a lot
exactly what I want !
0
All Courses

From novice to tech pro — start learning today.