This code will allow you to disable alt + f4, ctrl + alt + del, alt + tab, alt + esc, windows key, ctrl + esc.
Sample code:
Public Class Form1
Public g_IniSettings As New IniFile
#Region "Alt + F4"
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const CS_NOCLOSE As Integer = &H200
cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
Return cp
End Get
End Property
Friend Sub check_settings()
g_IniSettings.FileName = Application.StartupPath & "\ScreenLockSettings.ini"
Dim fi As New FileInfo(g_IniSettings.FileName)
If Not fi.Exists() Then
'MessageBox.Show("INI file not found:" & vbCrLf & vbCrLf & g_IniSettings.FileName, "Error")
End If
Try
' Application.Run(New frmSettings)
Catch e As Exception
' MessageBox.Show("Application Error:" & _
' vbCrLf & vbCrLf & e.ToString, "Error")
End Try
End Sub
Dim terminateProgram As Integer = 0
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown, TextBox1.KeyDown, Button1.KeyDown
If e.KeyCode = Keys.Enter Then
Button1.PerformClick()
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Start()
check_settings()
g_IniSettings.FileName = Application.StartupPath & "\ScreenLockSettings.ini"
Dim fi As New FileInfo(g_IniSettings.FileName)
If Not fi.Exists Then
terminateProgram = 1
TopMost = False
Form2.Show()
Me.Hide()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1
.Text = g_IniSettings
.GetSetting("Role",
"Admin") Then
terminateProgram = 1
TopMost = False
Form2.Show()
Me.Hide()
ElseIf TextBox1
.Text = g_IniSettings
.GetSetting("Role",
"User") Then
End
Else
terminateProgram = 0
Timer1.Start()
TextBox1.BackColor = Color.Red
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If terminateProgram = 0 Then
TopMost = True
End If
End Sub
End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.