Click here to Skip to main content
14,390,052 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am tring to disable ctrl+Alt+del and windows buttton using C# with wpf

my program will traget Windows 7 and windows 8 .
Posted
Updated 10-Mar-18 6:18am
Comments
karthik Udhayakumar 25-Jan-14 9:34am
   
Hello,

Try this code

protected override void OnKeyDown(KeyEventArgs e)
{
if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F4 ||
Keyboard.Modifiers == ModifierKeys.Control && e.SystemKey == Key.Escape)
{
e.Handled = true;
}
else
{
base.OnKeyDown(e);
}
}
osamaworx 25-Jan-14 9:41am
   
thanks for attention , but unfortionately It dosent work !
Rate this:
Please Sign up or sign in to vote.

Solution 2

The code in the other solution only disables TaskManager. It does NOT disable Ctrl-Alt-Del. That key combination can NOT be disabled.

The Window key can only be disabled by writing a global keyboard hook and just not passing that key up the hook chain when your code sees it.

Also, if you're trying to stop people from stopping processes, the registry hack you were given in Solution 1 only prevent TaskManager from running. It will not stop other utilities from being used to do the exact same thing, like TaskList and TaskKill.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Please check below link.It may be helped to you.

How to Disable CTRL+ALT+DEL Key

Another Link : Possible to disable Control-Alt-Delete buttons

Here is the c# code

private void DisableTaskManager()
{
    RegistryKey regkey = default(RegistryKey);
    string keyValueInt = "1";
    string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
    try {
        regkey = Registry.CurrentUser.CreateSubKey(subKey);
        regkey.SetValue("DisableTaskMgr", keyValueInt);
        regkey.Close();
    } catch (Exception ex) {
        Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "Registry Error!");
    }

}



private void EnableTaskManager()
{
    RegistryKey regkey = default(RegistryKey);
    string keyValueInt = "0";
    //0x00000000 (0)
    string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
    try {
        regkey = Registry.CurrentUser.CreateSubKey(subKey);
        regkey.SetValue("DisableTaskMgr", keyValueInt);
        regkey.Close();
    } catch (Exception ex) {
        Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "Registry Error!");
    }

}


You can use This Free Tool to convert it: Convert VB.NET to C#
   
v3
Comments
osamaworx 25-Jan-14 9:43am
   
yes thank you , but I already read it but the script was writen by VB , I am not familiar with it , I need C# Script.
Sampath Lokuge 25-Jan-14 9:48am
   
I have updated my answer.Please check that.
Ron Beyer 25-Jan-14 9:52am
   
Unfortunately to run this code you will have to run the program with administrative permissions.
osamaworx 25-Jan-14 10:06am
   
First of all I am really thank you too mutch for yor help , and I will work on try this ways .
Sampath Lokuge 25-Jan-14 10:07am
   
OK sure.No problem :)
osamaworx 26-Jan-14 18:45pm
   
thanx too much it s working .. :)
Sampath Lokuge 27-Jan-14 1:54am
   
Thanks.Glad to hear it! Best of luck. :)
tlhIn`toq 25-May-15 10:53am
   
25may2015 - Solution 1: Disable/enable task manager - Does not seem to work in Windows 10. MS probably overhauled the task manager, or moved the location for system policies registry value.
LePixeL 18-Oct-15 17:02pm
   
It works fine on windows 10..
Although setting the DisableTaskMgr back to 0 doesnt work
I just delete the key when I am done.
private void EnableTaskManager()
{
RegistryKey regkey = default(RegistryKey);
string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
try
{
regkey = Registry.CurrentUser.CreateSubKey(subKey);
regkey.DeleteValue("DisableTaskMgr");
regkey.Close();
//MessageBox.Show("EnabledTaskMAnager");
}
catch (Exception ex)
{
MessageBox.Show("Registry Error!");
}

}
Member 12923287 4-Jan-17 2:25am
   
this is working in usermode??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100