怎么在注册表中修改 “禁用脚本调试 (IE)”此项的健值,我已找到它在注册表的位置“HKEY_CURRENT_USER\Software\Microsoft\Internet\Explorer\Main\DisableScriptDebuggerIE”,但怎么调整路径,老是有“未将对象引用设置到对象的实例”这样的报错
我的代码是以下这些,请各位大虾指点指点,最好给出可以用的代码。
            RegistryKey regKey = Registry.CurrentUser;
            string SubKeyPath;
            RegistryKey optionKey;
            try
            {                SubKeyPath = @"Software\Microsoft\Internet\Explorer\Main";
                optionKey = regKey.OpenSubKey(SubKeyPath, true);                optionKey.SetValue("DisableScriptDebuggerIE", "no");
            }
            catch
            {}

解决方案 »

  1.   

    路径错了,Internet\Explorer之间应该是空格吧
      

  2.   

    在取值或改值之前也可以先做个判断
                      RegistryKey rsg = null;
                    rsg = Registry.LocalMachine.OpenSubKey(@"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\", true);
                    if (rsg.GetValue("DisableScriptDebuggerIE") != null) //读取失败返回null
                    {
                        //然后再读或是写值.
                    }
                    rsg.Close();