maitovasanthinet
asked on
Disable keys in C# program (Alt+Tab,Alt+F4,ctr+Alt+Delete )
Dear Friends,
How do disable the Alt+Tab,Alt+F4,ctr+Alt+Del ete butttons from C# program?
Can anybody give me a clue or sample code?
Thanks in advance.
Thanks,
maitovasanthinet
How do disable the Alt+Tab,Alt+F4,ctr+Alt+Del
Can anybody give me a clue or sample code?
Thanks in advance.
Thanks,
maitovasanthinet
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, the solution I gave you catches only some of the key combinations you want, it does not catch Ctrl+Alt+Del for example....
To TheAvenger:
Your code works nice for Alt+f4, as Alt+F4 actualy only send close message to actual windows, so you can catch it and ignore it.
But ctrl+alt+delete, alt+esc or alt+tab don't do it. They are processed by the system (at least in WinXP and WinNT) and actual process don't receive any notification about it.
Your code works nice for Alt+f4, as Alt+F4 actualy only send close message to actual windows, so you can catch it and ignore it.
But ctrl+alt+delete, alt+esc or alt+tab don't do it. They are processed by the system (at least in WinXP and WinNT) and actual process don't receive any notification about it.
To martinv:
I got it :-( and I wrote that in the second comment so that the guy knows what it actually can do...
I got it :-( and I wrote that in the second comment so that the guy knows what it actually can do...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to TheAvenger:
sorry, I've written the comment before your second coment. I was too quick :-)
as for meliorasoft - thank you for pointing to the site. It looks wery interesting. Their documentation says that they are installing kernel level keyboard filter. It's smart and it should work. But drawback is, that you have to run under administrator account to install such a hook. It's mentioned in their doc.
More over under Windows XP restart is needed. It's suitable for some scenarios such as information kiosk but not for normal application.
sorry, I've written the comment before your second coment. I was too quick :-)
as for meliorasoft - thank you for pointing to the site. It looks wery interesting. Their documentation says that they are installing kernel level keyboard filter. It's smart and it should work. But drawback is, that you have to run under administrator account to install such a hook. It's mentioned in their doc.
More over under Windows XP restart is needed. It's suitable for some scenarios such as information kiosk but not for normal application.
protected override bool ProcessCmdKey(ref System.Windows.Forms.Messa
{
if (keyData == (Keys.Alt | Keys.F4)) {
MessageBox.Show ("Alt + F4 catched!");
return true; // The key is manually processed
} else
return base.ProcessCmdKey (ref msg, keyData);
}
You can catch the other key combinations as well. For more info see the ProcessCmdKey function in MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassprocesscmdkeytopic.asp