Sniper167

How would I disable the key combination Ctrl+Alt+Del in my application and pop up a messagebox with a message in it



Re: Visual C# General Disable Ctrl+Alt+Del in my application

Martin Platt

I wouldn't imagine that you'd really want to do that, what happens if you need to use that combination

However, you should instead catch the closing of the form and stuff, and handle that...

If you have more information on what the purpose is of disabling, then fire another post across and I'll try to come up with a solution for you.






Re: Visual C# General Disable Ctrl+Alt+Del in my application

Spoofer

I thought it was something with the keypress event of the form..
But when i looked up the possible keys in msdn you could intercept i see that you can't catch an ALT key.
Delete and Control are no problem..

from a console app standpoint i thought it was something like this.
But the combination in the if doesn't work. It just fires of the normal ctrl+alt+del action.
If you only check for ctrl and del, this code works.

Code Snippet

ConsoleKeyInfo key;
key = Console.ReadKey();
if(key.Key==ConsoleKey.Delete&&key.Modifiers==ConsoleModifiers.Control&&key.Modifiers==ConsoleModifiers.Alt)
{
MessageBox.Show("Hello you!");
}






Re: Visual C# General Disable Ctrl+Alt+Del in my application

Martin Platt

That's not true, you can get to all the keys, the problem is more that CTRL + ALT + DEL has specific operating system meaning, so would be intercepted by the operating system when the windows messages are processed, if you see what I mean

You're trying to intercept the combination from a Console read, which I wouldn't imagine to be a very likely scenario

You can intercept the keypress, keydown and keyup events in a form for example, and easily look at all those keys. You need to have keypreview set to true for that magic to work.

I hope that helps you a little,

Martin.






Re: Visual C# General Disable Ctrl+Alt+Del in my application

Sniper167

You see, I'm making an application where the user would not be able to exit the application using the task manager because I don't even want the task manager showing up so I wanted to disable that key combination altogether until they click a certain button on the form...





Re: Visual C# General Disable Ctrl+Alt+Del in my application

Martin Platt

I suspect that what you may really want is a service, as that has no interface.

I think disabling things like that is dangerous, what happens if the application crashes You need to think about why you want to do that, and whether there are better solutions to the problem than that...

I hope that helps you,

Martin.






Re: Visual C# General Disable Ctrl+Alt+Del in my application

Sniper167

I understand the risks but I still want to followthrough with it if you could just help me with the code please...





Re: Visual C# General Disable Ctrl+Alt+Del in my application


Re: Visual C# General Disable Ctrl+Alt+Del in my application

Sniper167

That helps! Thank you...