Home c# Keyboard shortcuts Alt + F4 and Ctrl + Alt + Del

Keyboard shortcuts Alt + F4 and Ctrl + Alt + Del




Everyone knows that the combinations of the alt + f4 completes the program, or rather turns off the first window, and the KBD key combinations are Ctrl + Alt + Del Calls Task Manager.

Is it possible to write code that when you running the program, did not react to these combinations of the keys, well, or issued messages in messenger boxing?

Answer 1, Authority 100%

alt + f4 only Sends the window message WM_CLOSE . The program can respond to this message closing window, and may not react.

ctrl + alt + del is processed by the system and applications not sent. In order to intervene in his work, you will have, I'm afraid to descend the keyboard driver level.

about Ctrl + Alt + Del, here is the translation of Answer with ServerFault :

Windows kernel (NT) is designed in this way: it reserves an alert about this key combination only for the WinLogon system process. Thus, if Windows works correctly, no user application can process this key combination. If it could, it would be able to show the user a fake screen login and thus intercept his password;)

Here is This article says that

Slim out CTRL-ALT-DEL sequence using SendKeys will not work. Pressing Ctrl-Alt-Del causes a hardware interrupt, through a straight separate key on the keyboard.

That is, it will not be possible to intercept it.


Answer 2, Authority 17%

I will not say about alt + f4 , but on ctrl + alt + del Put a hook, as far as I know, it is impossible, and, accordingly, you cannot attach any actions.

p.s. In any case, it's not all done on C #, only si, only hardcore.

Answer 3

Interception ALT + F4 :

public form1 ()
    Initializecomponent ();
    this.KeyPreView = True;
  PROTECTED OVERRIDE VOID OnKeydown (Keyeventargs E)
    Base.ONKEYDOWN (E);
    if (E.KEYCode == Keys.f4 & amp; & amp; e.alt)
      MessageBox.Show ("Test");
      E.HandLed = True;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions