Hi Weecom
With this code you can check in your main form (event me.FormClosing) who try to close your application:
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Select Case e.CloseReason
Case CloseReason.ApplicationExitCall
MsgBox("'ApplicationExitCall' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.FormOwnerClosing
MsgBox("'FormOwnerClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.MdiFormClosing
MsgBox("'MdiFormClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.TaskManagerClosing
e.Cancel = True
MsgBox("'TaskManagerClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.UserClosing
MsgBox("'UserClosing' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.WindowsShutDown
MsgBox("'WindowsShutDown' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case CloseReason.None
MsgBox("'None' tries to close application", MsgBoxStyle.Information, "CloseReason")
Case Else
MsgBox("'Else' tries to close application", MsgBoxStyle.Information, "CloseReason")
End Select
End Sub
with e.Cancel = True you can avoid the first try to abort the application by Task Manager or other CloseReasons
Hope this can help you.
Regards Markus