各位高手以下是我写的一个注册表文件Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\TAW\BSE]
"DSN"="TAWReports"
"User"="TAW1"
"Password"="taw1.1"
"Server"="dbserver"
"IP"=""请问如何使用RegistryKey读取出来啊,谢谢了!

解决方案 »

  1.   

    using Microsoft.Win32;                    
                         RegistryKey SoftwareKey=Registry.LocalMachine.OpenSubKey("Software",true);
                         RegistryKey MovecontKey=SoftwareKey.OpenSubKey("TAW");
                         RegistryKey SelfPlaceKey=MovecontKey.OpenSubKey("TAW");
                         string s=SelfPlaceKey.GetValue("DSN");
                         string d=SelfPlaceKey.GetValue("User");
                         string f=SelfPlaceKey.GetValue("Password");
                         string m=SelfPlaceKey.GetValue("Server");
                         string m=SelfPlaceKey.GetValue("IP");参考下!
      

  2.   

    RegistryKey MovecontKey=SoftwareKey.OpenSubKey("TAW"); 
    RegistryKey SelfPlaceKey=MovecontKey.OpenSubKey("BSE]"); 
      

  3.   

    报了一个异常未处理的异常:  System.NullReferenceException: 未将对象引用设置到对象的实例。
       在 Book1.MyClass.Main(String[] args) 位置 C:\Documents and Settings\Administr
    ator\桌面\Book1\Book1\MyClass.cs:行号 16
    请按任意键继续. . .
      

  4.   

    using Microsoft.Win32;                     
    RegistryKey SoftwareKey = Registry.CurrentUser.OpenSubKey("Software", true);
                         RegistryKey MovecontKey=SoftwareKey.OpenSubKey("TAW"); 
                         RegistryKey SelfPlaceKey=MovecontKey.OpenSubKey("BSE]"); 
                         string s=SelfPlaceKey.GetValue("DSN").ToString(); 
                         string d=SelfPlaceKey.GetValue("User").ToString(); 
                         string f=SelfPlaceKey.GetValue("Password").ToString(); 
                         string m=SelfPlaceKey.GetValue("Server").ToString(); 
                         string m=SelfPlaceKey.GetValue("IP").ToString(); 
    这样应该行了
      

  5.   

    刚才我写的是打开LOCALmachine的了
      

  6.   

    RegistryKey SelfPlaceKey=MovecontKey.OpenSubKey("BSE");
    这个就是BSE,我多写了个括号!你删了,不然又要出错了!  
      

  7.   

    对了大哥你是怎么学c#那么好的,小弟是北大青鸟的学员,刚学完JSP,正在学C#,我感觉Java方向很难学,所以就转投.Net方向了,请大哥指点迷津