65.9K
CodeProject is changing. Read more.
Home

Enabling and Disabling TaskManager

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.17/5 (3 votes)

Jun 28, 2011

CPOL
viewsIcon

15741

Couldn't the class RegEdit be replaced by one simple method?private void SetKey(bool enableTaskManager) { using ( var mKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")) {...

Couldn't the class RegEdit be replaced by one simple method?
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);
              }
          }
      }