每个子键中都有一个 (默认) 的键值 
这个默认的键值怎么取呢 ?例如:HKEY_CLASSES_ROOT\Excel.Application\CurVer  中个(默认)的键值 这个键值存储的是当前系统
Office Excel的版本 但是 Registry.ClassesRoot.OpenSubKey(@"Excel.Application\CurVer",true).
GetValue("这个参数是什么?");
换成Registry.ClassesRoot.OpenSubKey(@"Excel.Application").GetValue("CurVer") 排除语法错误 ,排除注册表路径拼写错误。 但是取出的对象是Null!
在线等操作注册表的强手指教 

解决方案 »

  1.   

    默认的没有名字,就用空来取就可以。
    string version = Registry.ClassesRoot.OpenSubKey(@"Excel.Application").OpenSubKey("CurVer").GetValue("").ToString();
      

  2.   

    RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(mainKey);
    string s = regKey.GetValue("").ToString();
    object o=regKey.GetValue("");
      

  3.   


    private void ButtonOpen_Click(object sender, System.EventArgs e) 
    {
        String editingFileName = "";
        Boolean saveAllowed = true;    // Displays the OpenFileDialog.
        if (openFileDialog1.ShowDialog() == DialogResult.OK) 
        {
            // Opens the file stream for the file selected by the user.
            using (System.IO.Stream userStream = openFileDialog1.OpenFile()) 
            {
                this.RtfBoxMain.LoadFile(userStream,
                    RichTextBoxStreamType.PlainText);
                userStream.Close();
            }        // Tries to get the file name selected by the user.
            // Failure means that the application does not have
            // unrestricted permission to the file.
            try 
            {
                editingFileName = openFileDialog1.FileName;
            } 
            catch (Exception ex) 
            {
                if (ex is System.Security.SecurityException) 
                {
                    // The application does not have unrestricted permission 
                    // to the file so the save feature will be disabled.
                    saveAllowed = false; 
                } 
                else 
                {
                    throw ex;
                }
            }
        }
    }
      

  4.   

    private void ButtonOpen_Click(object sender, System.EventArgs e) { String editingFileName = ""; Boolean saveAllowed = true; // Displays the OpenFileDialog.  if (openFileDialog1.ShowDialog() == DialogResult.OK) { // Opens the file stream for the file selected by the user.  using (System.IO.Stream userStream = openFileDialog1.OpenFile()) { this.RtfBoxMain.LoadFile(userStream, RichTextBoxStreamType.PlainText); userStream.Close(); } // Tries to get the file name selected by the user. // Failure means that the application does not have // unrestricted permission to the file.  try { editingFileName = openFileDialog1.FileName; } catch (Exception ex) { if (ex is System.Security.SecurityException) { // The application does not have unrestricted permission // to the file so the save feature will be disabled.  saveAllowed = false; } else { throw ex; } } } }