Disable CTRL/DELETE and other keys in WinNT 4 (SP3 and above)

screen-shot

There are many situations when it's need to disable some combinations of keys from a VB program. For instance, ALT-TAB, CTRL-ESC, ALT-ESC or others like these. Other combinations could be tested at form level using KeyPreview property and KeyPress / KeyDown / KeyUp events. All system keystrokes won't fire key events in a form (or other controls) because they are handled internally by the system. Since application threads never receive messages for these keystrokes, there is no way that an application can intercept them and prevent the normal processing. This behavior is "by design" and ensures that a user can always switch to another application.s window even if an application.s thread enters an infinite loop or hangs.

The question is how we can intercept this keystrokes? The solution could be achieved using hooks. A hook is a point in the Microsoft Windows message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure.
For Windows NT SP3 (or higher), Microsoft introduced a new hook: WH_KEYBOARD_LL. This hook is called the low-level hook because it is notified of keystrokes just after the user enters them and before the system gets a chance to process them. This hook has a serious drawback: the thread processing the hook filter function could enter an infinite loop or hang. If this happens, then the system will no longer process keystrokes properly and the user will become incredibly frustrated. To alleviate this situation, Microsoft places a time limit on low-level hooks. When the system sends a notification to a low-level keyboard hook.s filter function, the system allows that function a fixed amount of time to execute. If the function does not return in the allotted time, the system ignores the hook filter function and processes the keystroke normally. The amount of time allowed (in milliseconds) is set via the LowLevelHooksTimeout value under the following registry subkey: HKEY_CURRENT_USER\Control Panel\Desktop.

The program (VB) is disabling some of these combinations (ALT-TAB, CTRL-ESC and ALT-ESC) as long as the option is checked.

Download zipped project files (8k)



Comments

  • disable ctrl+alt+del

    Posted by Legacy on 12/16/2003 12:00am

    Originally posted by: adam

    like alot of the messages poted on this site i also want to disable alt+clrl+del on my vb program is there a piece of coding you can give me which will do this
    

    • disable ctrl+alt+del

      Posted by DEX348 on 04/03/2004 05:00pm

      KeyboardControl SDK does the trick http://www.meliorasoft.com/kits/keyboard/

      Reply
    Reply
  • Windows Key 2 (Vb.Net Version)?

    Posted by Legacy on 11/22/2003 12:00am

    Originally posted by: Myr_Enforcer

    is it possible to disable the windows key in vb.net? How? pls help...

    • hi

      Posted by sniperald on 04/11/2005 04:05am

      good

      Reply
    Reply
  • What the?!?!

    Posted by Legacy on 11/05/2003 12:00am

    Originally posted by: Me

    I used some cut and paste action into one of my games (where alt and tab were both weapons firing commands) buuuut it works when its not running but doesn't when it is running...

    What the?

    Reply
  • thats how to disable ctrl+alt+del on win NT & XP

    Posted by Legacy on 07/25/2003 12:00am

    Originally posted by: JoK

    make a sub procedure like

    timer1_timer()
    on error resume next
    kill sysdir & "\taskmgr.exe"
    end sub
    (Here timer1 should have the interval between events from 50 to 200 miliseconds)

    ------------- or ----------------------------------------

    do while not stop
    on error resume next
    kill sysdir & "\taskmgr.exe"
    loop

    (Here stop should be a boolean variable set to true, all
    other things the program should do have to be in put between the do ... loop cicle and should not last long if you don't wanna ghive a chance to the user because the taskmanager application will be created ever and ever, 1-2 seconds after it was deleted.)
    !!! In both cases you should put the <On Error Resume Next> and the sysdir should be the retrieved value
    from getsystemdir API function!!!

    Reply
  • none

    Posted by Legacy on 07/25/2003 12:00am

    Originally posted by: JoK

    Astia-s cam tampiti, tu le vinzi un pont mura-n gura si ei te-ntreba cate varfuri are cuiul. Nashpa zau daca nu. Apropo eu is din Arad tu de pe unde esti?

    Reply
  • ASCII value for DELETE key ???

    Posted by Legacy on 07/15/2003 12:00am

    Originally posted by: raj

    What is the ASCII value for DELETE key ????

    Reply
  • Disable Taskmanager with Regedit

    Posted by Legacy on 06/15/2003 12:00am

    Originally posted by: me

    Hive: HKEY_CURRENT_USER 
    
    Key: Software\Microsoft\Windows\CurrentVersion\Policies\System
    Name: DisableTaskMgr
    Type: REG_DWORD
    Value: 1=Enablethis key, that is DISABLE TaskManager
    Value: 0=Disablethis key, that is Don't Disable, Enable TaskManager

    Reply
  • diable ctrl+alt+del

    Posted by Legacy on 04/25/2003 12:00am

    Originally posted by: jai

    how to disable ctrl+alt+del through vb in registry?

    Reply
  • You ROCK!!!

    Posted by Legacy on 04/08/2003 12:00am

    Originally posted by: CODE MASTER

    You ROCK!!!

    Reply
  • how to disable hotkey in IE6

    Posted by Legacy on 03/20/2003 12:00am

    Originally posted by: Marcus

    how to disable hotkey in IE6 / Windows (ctrl-N = New, ctrl-S = Save, etc)
    I want to know to protect my screen.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

Most Popular Programming Stories

More for Developers

RSS Feeds