Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

intercept Windows Shutdown

Status
Not open for further replies.

prettitoni

Programmer
Apr 22, 2004
74
US
Hi there. I need to intercept a call to Shutdown or Log Off thru a VB6 application. I found this code, but it doesn't appear to work:

Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbAppWindows Then
        'Windows is shutting down; put code here
    End If
End Sub
 
In what way is it failing?

Note that this event can only trap your application being requested to close, by a variety of methods such as Windows shutdown or user logout; and it only detects this when your application's process is sent the WM_SHUTDOWN message - if your process is the last in the process list, then everything else will have been closed/exited before the event fires.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top