views:

248

answers:

2

I am working on a Kiosk application, i need to disable the taskmanager. So that when the user press [ctrl + alt + Del] and [ctrl + shift + escape], the taskmanager should not pop up. How ?

+4  A: 

You can do it by changing the group policy settings.

http://tamaspiros.co.uk/2007/12/20/c-disable-ctrl-alt-del-alt-tab-alt-f4-start-menu-and-so-on/

    public void KillCtrlAltDelete()
    {
        RegistryKey regkey;
        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)
        {
            MessageBox.Show(ex.ToString());
        }
    }
Sam
Beat me and much more nicely factored than mine :)
fmark
@Sam, It is possible to enable it back ?
Anuya
@srk, sure, just remove the registry value.
Sam
@Sam, Remove the registry value ? How ?
Anuya
@srk, use `RegistryKey.DeleteSubKey`
Sam
@srk Or set the value to 0 instead of 1
fmark
+1  A: 

Just set the appropriate registry key:

public void SetRegistryKey(Microsoft.Win32.RegistryKey regHive, string regKey, string regName, string regValue)
{
    bool response = false;

    Microsoft.Win32.RegistryKey key = regHive.OpenSubKey(regKey);
    if (key == null)
    {
        regHive.CreateSubKey(regKey, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
    }
    key = regHive.OpenSubKey(regKey,true);
    key.SetValue(regName, (string)regValue);
}

SetRegistryKey(RegistryHive.CurrentUser, "Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 1)
fmark