How can I intercept all key events, including ctrl+alt+del and ctrl+tab?

后端 未结 12 1330
眼角桃花
眼角桃花 2020-11-28 13:06

I\'m writing a screen saver type app that needs to stop the user from accessing the system without typing a password. I want to catch/supress the various methods a user migh

相关标签:
12条回答
  • 2020-11-28 13:32

    It is possible to intercept crtl+alt+del, though obviously Microsoft made it very difficult to do, because then you could pop-up a fake lock dialog, and record people's passwords.

    The answer is to write a device driver. I can't remember if you can just use a plain old keyboard filter, or if you have to write a keyboard ISR. Either way, its certainly possible, but with great pain if you have no driver experience.

    0 讨论(0)
  • 2020-11-28 13:32

    You could achieve that in XP and before, but with Vista not anymore.

    0 讨论(0)
  • 2020-11-28 13:38

    Try investigating if you could write an application that starts itself as a password protected screensaver.

    Screensavers can do more than just display pretty pictures - I've seen interactive screensavers before that used the mouse and keyboard to provide a simple game, though I can't remember which version of windows I saw this running on... It could well have been windows 95. (In which case all bets are off).

    0 讨论(0)
  • 2020-11-28 13:39

    What about intercepting ctrl and alt keypresses while your program is running, and .cancel'ing those keypresses?

    I don't know how well this would work, if at all in Vista, but it's worth a try.

    I remember doing something like this around the year 2001, so it was probably running on 98. Been too long since I've even tried to mess with anything like locking out ctrl-alt-del.

    0 讨论(0)
  • 2020-11-28 13:39

    starting taskmgr.exe in hidden window would do the job if you just wanted to suppres the call to task manager

        ProcessStartInfo taskmgr = new ProcessStartInfo()
        {
            FileName = "taskmgr.exe",
            WindowStyle = ProcessWindowStyle.Hidden
        };
    
        Process.Start(taskmgr);
    
    0 讨论(0)
  • 2020-11-28 13:47

    I have not tested it but what about using SetWindowsHookEx()

    From MSDN documentantion: WH_KEYBOARD_LL

    Windows NT/2000/XP: Installs a hook procedure that monitors low-level keyboard input events. For more information, see the LowLevelKeyboardProc hook procedure.

    0 讨论(0)
提交回复
热议问题