sir,
I got a solution by using follwing code:
Private Sub formPOS_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If (systemShutdown) Then
' Reset the variable because the user might cancel the shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes =
MessageBox.Show("My application", "Do you want to save your work before logging off?", MessageBoxButtons.YesNo)) Then
updateloginlogs()
e.Cancel = True
Else
updateloginlogs()
e.Cancel = False
End If
End If
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
updateloginlogs()
systemShutdown = True
End If
updateloginlogs()
' If this is WM_QUERYENDSESSION, the closing event should be raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc