none
TreeView and TreeNodes RRS feed

  • Question

  •      I'm working on a program that returns a registry key's path.  The path always return in the format "Root_Key\Subkey\Subkey\key".  I also have a list that stores the subkeys found and I need a way that I can read from its path and add each path individually to a treeview's list so it will be like regular RegEdit, but it only shows what you have searched for.

    Monday, November 27, 2006 8:32 PM

Answers

  • Hi,

    Please try the below code. hope this helps. Set the registry path.

    string strWindowsState;

    string strPath;

     

    Read from Registry:-

    RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath); 

                 strWindowsState = (string)regKeyAppRoot.GetValue("WindowState"); 

                if (strWindowsState != null && strWindowsState.CompareTo("Maximized") == 0)

                    WindowState = System.Windows.Forms.FormWindowState.Maximized; 

                else if (strWindowsState != null && strWindowsState.CompareTo("Minimized") == 0)

                    WindowState = System.Windows.Forms.FormWindowState.Minimized; 

                else

                    WindowState = FormWindowState.Normal;

                label1.Text = strWindowsState;

                label3.Text = "";

     

    Writing into Registry:-

     

    strWindowsState = "";

                RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath); 

                if (WindowState == FormWindowState.Maximized)

                    strWindowsState = "Maximized"; 

                else if(WindowState == FormWindowState.Maximized)

                    strWindowsState = "Minimized"; 

                else

                     strWindowsState = "Normal"; 

                 regKeyAppRoot.SetValue("WindowState", strWindowsState);

                 label3.Text = strWindowsState;

                 label1.Text = "";

     

    thank you,
    bhanu.

    Monday, November 27, 2006 10:38 PM

All replies

  • Have you Tried RegistryClass.GetSubKeyNames() and GetValueNames??? you can concatincate this name with the path of registry key to get full path.

    I hope this will help.

    Best Regards,

    Rizwan

    Monday, November 27, 2006 8:57 PM
  • I have no problem returning the path of the keys.  I need to read from the path per say "hkey_users\key1\key2" and have the parent node added "hkey_users" and add the sub key "key1" and insert the sub key "key2" in"key1".
    Monday, November 27, 2006 9:06 PM
  • Hi,

    Please try the below code. hope this helps. Set the registry path.

    string strWindowsState;

    string strPath;

     

    Read from Registry:-

    RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath); 

                 strWindowsState = (string)regKeyAppRoot.GetValue("WindowState"); 

                if (strWindowsState != null && strWindowsState.CompareTo("Maximized") == 0)

                    WindowState = System.Windows.Forms.FormWindowState.Maximized; 

                else if (strWindowsState != null && strWindowsState.CompareTo("Minimized") == 0)

                    WindowState = System.Windows.Forms.FormWindowState.Minimized; 

                else

                    WindowState = FormWindowState.Normal;

                label1.Text = strWindowsState;

                label3.Text = "";

     

    Writing into Registry:-

     

    strWindowsState = "";

                RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strPath); 

                if (WindowState == FormWindowState.Maximized)

                    strWindowsState = "Maximized"; 

                else if(WindowState == FormWindowState.Maximized)

                    strWindowsState = "Minimized"; 

                else

                     strWindowsState = "Normal"; 

                 regKeyAppRoot.SetValue("WindowState", strWindowsState);

                 label3.Text = strWindowsState;

                 label1.Text = "";

     

    thank you,
    bhanu.

    Monday, November 27, 2006 10:38 PM