954,558 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to get the event when system shuts down in Visual Basic 6.0

Hai All,
This is Mahesh, I want to create an application in Visual Basic 6.0 that runs in Background and is invoked when system is going to shut down. Can anyone tell me what is the event that is activated in Visual Basic6.0 when system shuts down.
Thanks in Advance
Mahesh Gupta.B

mahesh_gupta024
Newbie Poster
2 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

Hi there.

The only way I know of how to pick up on the Windows log off event is to have code in the Query_Unload of the form. See below.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
    'Unload modes
    '0   The user has chosen the Close command from the Control-menu box on the form.
    '1   The Unload method has been initiated from code.
    '2   Windows is logging off.
    '3   Task Manager is closing the application.
    '4   An MDI child form is closing because the MDI form is closing.
    
    Select Case UnloadMode
        
        Case 2
            'Windows is logging off.  System initiated close
            'Do your stuff here
            
        Case Else
            Debug.Print "Unload mode: " & CStr(UnloadMode)
            
    End Select
    
End Sub
Sentax
Newbie Poster
18 posts since Nov 2006
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You