Home  >  Q&A  >  body text

c++ - 自定义Url协议报错,需要管理员权限,如何取消权限限制?

自定义url协议只能用管理员权限?不用管理员权限是否可行?
代码:

            var surekamKey =    Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("hello");
            //以下这些参数都是固定的,不需要更改,直接复制过去 
            var shellKey = surekamKey.CreateSubKey("shell");
            var openKey = shellKey.CreateSubKey("open");
            var commandKey = openKey.CreateSubKey("command");
            surekamKey.SetValue("URL Protocol", "");

错误信息:

System.UnauthorizedAccessException: Access to the registry key 'HKEY_CLASSES_ROOT\hello' is denied.

我用管理员权限运行没这个问题

伊谢尔伦伊谢尔伦2765 days ago581

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:58:45

    What operating system?
    Systems after Win7 use the UAC mechanism. You can set the program to run with administrator privileges by default
    http://www.veryhuo.com/a/view/35011.html

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:58:45

    You are accessing and modifying the Windows registry, of course you need administrator rights

    reply
    0
  • Cancelreply