简体   繁体   中英

How do I disable all exiting in Visual Basic

I'm writing an examination piece of software for my workplace and would like to know how I can trap and cancel key-presses such as:

  • ALT+F4
  • WIN+TAB
  • ALT+TAB
  • WIN
  • CTRL+ALT+DEL

I'm aware CTRL+ALT+DEL may not be possible, but if any of this is it'll be a step in the right direction!

Ideally I want to prevent the action, and then open a new form I've created saying 'Unauthorised keypress'

as @SQLHound link relates... us the FormClosing event to handle what happens when a user attempts to close. But if you want to block a boot attempt, then @Plutonix suggestion may help. Something along these lines...

       Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing

         Dim splashScreen as New Form
         splashScreen.OpenDialog
         e.Cancel=True

       End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM