Mar 5, 2017 10:58 AM
(This post was last modified: Oct 3, 2017 03:50 PM by Xogg.)
So this thread will show you a few snippets of code to make your applacation un-closable. So the first thing you will need to do is remove the "X" button on the app.
You also will need to remove it from the TaskBar, use the following code to do so.
From here we want to disable the task manager and CMD so the user can not close it like that. Use this code in a timer to do so
Then we need to disable right click in our app use the following code to do so.
Also no need to worry that will only disable in that app! :)
Now there is one more thing we will do the be 100% sure that this is unclosable this will handle all other close methods.
Code
Me.ControlBox = FalseYou also will need to remove it from the TaskBar, use the following code to do so.
Code
Me.ShowInTaskbar = FalseFrom here we want to disable the task manager and CMD so the user can not close it like that. Use this code in a timer to do so
Code
Try
Dim p As Process
For Each p In Process.GetProcesses
If p.ProcessName = "taskmgr" Then
p.Kill()
End If
If p.ProcessName = "cmd" Then
p.Kill()
End If
Next
Catch ex As Exception
End Try
End SubThen we need to disable right click in our app use the following code to do so.
Code
Try
Dim Registry As Object
Registry = CreateObject("WScript.Shell")
Registry.RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" & "\NoViewContextMenu", 0, "REG_DWORD")
Catch
End TryAlso no need to worry that will only disable in that app! :)
Now there is one more thing we will do the be 100% sure that this is unclosable this will handle all other close methods.
Code
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Dim i As Integer = 0
If i = 0 Then
If (e.CloseReason = CloseReason.UserClosing) Then
e.Cancel = True
End If
End If
End Sub

![[Image: F2G97kn.png]](https://i.imgur.com/F2G97kn.png)

![[Image: f4hRdFS.gif]](https://i.imgur.com/f4hRdFS.gif)
![[Image: 49837582.jpg]](https://cdn.meme.am/cache/instances/folder582/500x/49837582.jpg)