search in registry

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Khali1
    New Member
    • Nov 2009
    • 1

    search in registry

    search in registry to find a key by its name and fill the keys and them values in datagridview
    please could you help me
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    What do you have so far for reading the registry?
    Do you know how to read / write a single registry entry when you know where it is located?

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      RegistryKey Class does everything for you.
      OpenSubKey

      MSDN sample code:
      Code:
      using System;
      using Microsoft.Win32;
      using Microsoft.VisualBasic;
      
      public class Example
      {
          public static void Main()
          {
              // Delete and recreate the test key.
              Registry.CurrentUser.DeleteSubKey("RegistryOpenSubKeyExample", false);
              RegistryKey rk = Registry.CurrentUser.CreateSubKey("RegistryOpenSubKeyExample");
              rk.Close();
      
              // Obtain an instance of RegistryKey for the CurrentUser registry 
              // root. 
              RegistryKey rkCurrentUser = Registry.CurrentUser;
      
              // Obtain the test key (read-only) and display it.
              RegistryKey rkTest = rkCurrentUser.OpenSubKey("RegistryOpenSubKeyExample");
              Console.WriteLine("Test key: {0}", rkTest);
              rkTest.Close();
              rkCurrentUser.Close();
      
              // Obtain the test key in one step, using the CurrentUser registry 
              // root.
              rkTest = Registry.CurrentUser.OpenSubKey("RegistryOpenSubKeyExample");
              Console.WriteLine("Test key: {0}", rkTest);
              rkTest.Close();
      
              // Open the test key in read/write mode.
              rkTest = Registry.CurrentUser.OpenSubKey("RegistryOpenSubKeyExample", true);
              rkTest.SetValue("TestName", "TestValue");
              Console.WriteLine("Test value for TestName: {0}", rkTest.GetValue("TestName"));
              rkTest.Close();
          } //Main
      } //Example
      Hope this helps.

      PS: Do take time to read the Posting Guidelines . We are here to help you with specific problems, not code for you.

      Comment

      Working...