RegistryKey Key=Registry.CurrentUser;
 RegistryKey key=Key.OpenSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",true);
key.SetValue("DisableMyPicturesDirChange",1);
key.Close();执行到 key.SetValue提示 未实例化  Registry实例化不是使用静态成员 OpenSubKey,或者使用 Registry 类的静态成员么?怎么还提示没有实例化呢??
大家帮帮忙!!

解决方案 »

  1.   

    自己顶一下 RegistryKey key=new RegistryKey()
    这样的话提示 给构造函数传递参数有问题 RegistryKey类的构造函数参数是什么?怎么找不到阿?
      

  2.   

    RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B83FC273-3522-4CC6-92EC-75CC86678DA4}",true);
      

  3.   

    Opensubkey()这里没有问题 
    现在是执行到 SetValue的时候出的错 未将对象引用设置到对象的实例
    也就是说我得key没有实例化? 
    请大家帮帮忙 分不够再加!!!
      

  4.   

    未将对象引用设置到对象的实例引起这个错误的原因不一定是key没有实例化.还有可能使你传入的值为空.
      

  5.   

    DisableMyPicturesDirChange 就是\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer下面的一个子键啊
      

  6.   

    string strPath = Application.ExecutablePath;
                    RegistryKey rk = Registry.CurrentUser;
                    RegistryKey rk1 = rk.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", true);
                    rk1.SetValue("WinForm.exe", strPath);
                    rk1.Close();
                    rk.Close();