Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Enabling and Disabling TaskManager

4.17/5 (3 votes)
28 Jun 2011CPOL 15.7K  
Couldn't the class RegEdit be replaced by one simple method?private void SetKey(bool enableTaskManager) { using ( var mKey = Registry.CurrentUser.CreateSubKey(SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem)) {...
Couldn't the class RegEdit be replaced by one simple method?
C#
private  void SetKey(bool enableTaskManager)
      {
          using (
              var mKey =
                  Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"))
          {
              if (mKey != null)
              {
                  mKey.SetValue("DisableTaskMgr", enableTaskManager ? 0 : 1);
              }
          }
      }

License

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