Connecting Tech Pros Worldwide Help | Site Map

search in registry

Newbie
 
Join Date: Nov 2009
Posts: 1
#1: 2 Weeks Ago
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's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,745
#2: 2 Weeks Ago

re: search in registry


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?
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 699
#3: 2 Weeks Ago

re: search in registry


RegistryKey Class does everything for you.
OpenSubKey

MSDN sample code:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using Microsoft.Win32;
  3. using Microsoft.VisualBasic;
  4.  
  5. public class Example
  6. {
  7.     public static void Main()
  8.     {
  9.         // Delete and recreate the test key.
  10.         Registry.CurrentUser.DeleteSubKey("RegistryOpenSubKeyExample", false);
  11.         RegistryKey rk = Registry.CurrentUser.CreateSubKey("RegistryOpenSubKeyExample");
  12.         rk.Close();
  13.  
  14.         // Obtain an instance of RegistryKey for the CurrentUser registry 
  15.         // root. 
  16.         RegistryKey rkCurrentUser = Registry.CurrentUser;
  17.  
  18.         // Obtain the test key (read-only) and display it.
  19.         RegistryKey rkTest = rkCurrentUser.OpenSubKey("RegistryOpenSubKeyExample");
  20.         Console.WriteLine("Test key: {0}", rkTest);
  21.         rkTest.Close();
  22.         rkCurrentUser.Close();
  23.  
  24.         // Obtain the test key in one step, using the CurrentUser registry 
  25.         // root.
  26.         rkTest = Registry.CurrentUser.OpenSubKey("RegistryOpenSubKeyExample");
  27.         Console.WriteLine("Test key: {0}", rkTest);
  28.         rkTest.Close();
  29.  
  30.         // Open the test key in read/write mode.
  31.         rkTest = Registry.CurrentUser.OpenSubKey("RegistryOpenSubKeyExample", true);
  32.         rkTest.SetValue("TestName", "TestValue");
  33.         Console.WriteLine("Test value for TestName: {0}", rkTest.GetValue("TestName"));
  34.         rkTest.Close();
  35.     } //Main
  36. } //Example
  37.  
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.
Reply