【问题标题】:C# - Disable Task manager errorC# - 禁用任务管理器错误
【发布时间】:2014-11-28 08:41:40
【问题描述】:

代码如下:

    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());
        }
    }

但我收到以下错误。

System.UnauthorizedAccessException:Access to the registry key'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System' is denied.

at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)

at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck, RegistrySecurity registrySecurity)

at BlockTask.Form1.KillCtrlAltDelete() in C:\Users\ASUS\Documents\Visual Studio 2008\Projects\BlockTask\BlockTask\Form1.cs:line 28

如何解决?

【问题讨论】:

  • 以管理员身份运行您的程序。
  • 使用 regedit,导航到该键,右键单击它并选择 Permissions.... 设置相应的权限。

标签: c# .net registry taskmanager


【解决方案1】:

尝试在管理员模式下运行此应用程序

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-21
    • 1970-01-01
    相关资源
    最近更新 更多