Prevent Windows Application (VB.Net)Termination

走远了吗. 提交于 2019-12-06 14:38:55

If you handle formclosing event and say e.cancel if it is a normal user then it will be handled in your boundary. But you cannot enforce policy until and unless there is physical restriction applies in windows. I feel if you can remove the .NET keyword and put the question to IT specific guys it will help. In .NET you can do other than what I have explained in the initial statement.

The following code will stop your form from closing (and should therefore stop your application closing) when the user hits the red X in the corner:

Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    If e.CloseReason = CloseReason.UserClosing Then e.Cancel = True
End Sub

You can't stop someone running task manager and killing the process though, but you can stop them from running task manager using group policy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!