Click here to Skip to main content
15,880,891 members
Please Sign up or sign in to vote.
4.00/5 (1 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 5: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 !

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.
 
Share this answer
 
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

C#
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!");
    }

}



C#
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#
 
Share this answer
 
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 :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900