代码如下:用注释的或者不注释的得出的都是  null或者键值不存在,为什么呢?注册表明明有的//string subNode = "HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Word\\Addins\\WebPage.Connect\\LoadBehavior";
            //Microsoft.Win32.RegistryKey rkey = null;
            //rkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(subNode, true);
            //try
            //{
            //    if (rkey != null)
            //    {
            //        rkey.SetValue("LoadBehavior", "3");
            //    }
            //    else
            //    {
            //        MessageBox.Show("null");
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //}
            RegistryKey key; //表示 Windows 注册表中的项级节点。此类是注册表封装。            key = Registry.CurrentUser.OpenSubKey("SoftWare\\Microsoft\\Internet Explorer\\Toolbar\\Explorer ", true);            if (key == null)
            {
                MessageBox.Show("键不存在");
            }
            else
            {
                key.SetValue("backbitmap", "c:\\windows\\greenstone.bmp");
            }

解决方案 »

  1.   

    "SoftWare\\Microsoft\\Internet Explorer\\Toolbar\\Explorer ":Explorer后有个空格。
      

  2.   

    key = Registry.CurrentUser.OpenSubKey("SoftWare\\Microsoft\\Internet Explorer\\Toolbar\\Explorer ", true);key应该是Subkey不是 RegistryKey吧
      

  3.   

    to:zhgroup(王员外) 
    "SoftWare\\Microsoft\\Internet Explorer\\Toolbar\\Explorer ":Explorer后有个空格。
    看的够仔细
      

  4.   

    是说不该有空格啊:
    // key = Registry.CurrentUser.OpenSubKey("SoftWare\\Microsoft\\Internet Explorer\\Toolbar\\Explorer", true);
    key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office\\Word\\Addins\\WebPage.Connect",true);
    // key.SetValue("backbitmap", "c:\\windows\\greenstone.bmp");
    key.SetValue("LoadBehavior", "0");