I need some help ..
i want to disable alt+tab .. and other shortcut keys to prevent the user from closing it unless you logout of the program..

Hi

Why would you want to do this? To what purpose?

It is generally bad practice to stop the user from being able to control their own machine. Also, this type of code can be used for malicious purposes (not suggesting that is your intent) and if given the solution, others may use it for such purposes.

Set your form's KeyPreview property to True and test for the key combinations you want to prevent in its KeyDown event, then set e.SuppressKeyPress = True

djjeavons .. uhmm my program is some kind of internet cafe . but instead ill be using it in a research lab .. users have to go through a security system before they can use the computer .. .

Then maybe you would be better served using some form of administration on the machines such as Group Policy to stop users from doing anything other than what they are allowed too, such as only running your application.

hi.
i have my code here that prevents alt+f4. maybe you can recycle and use it as alt+tab.

first go to form property then find key preview then on double click form load then the codes will appear, once you are there go to events (the combobox thing on the right top side of the code box thing, it has the word "Load" make it "KeyDown" then paste this,

    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If (e.Alt AndAlso e.KeyCode = Keys.F4) Then
            e.Handled = True
        End If

    End Sub

You can disable the TaskManager itself by editing the Windows Registry
Try:

to disable TaskManager:

Private Sub DisableTaskManager()
        Dim regkey As RegistryKey
        Dim keyValueInt As String = "1"
        Dim subKey As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
        Try
            regkey = Registry.CurrentUser.CreateSubKey(subKey)
            regkey.SetValue("DisableTaskMgr", keyValueInt)
            regkey.Close()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Registry Error!")
        End Try

    End Sub

    'Enable TaskManager

Private Sub EnableTaskManager()
    Dim regkey As RegistryKey
    Dim keyValueInt As String = "0"    '0x00000000 (0)
    Dim subKey As String = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
    Try
        regkey = Registry.CurrentUser.CreateSubKey(subKey)
        regkey.SetValue("DisableTaskMgr", keyValueInt)
        regkey.Close()
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Registry Error!")
    End Try

End Sub

You can disable the TaskManager itself by editing the Windows Registry

While the above may work, this code can be used for the wrong purposes such as Malware or other blocking code. If you are going to disable OS features because you are creating some form of kiosk application then you should lock down the machines using standard OS features. The Group Policy Editor allows you to do this without reverting to Registry editing code (no doubt it edits the Registry for you - not sure).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.