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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.