Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Registry Scan

Registry Scan

Scheduled Pinned Locked Moved C#
csharpwinformswindows-admintutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oskardiazdeleon
    wrote on last edited by
    #1

    I have been working with RegistryKeys (Create, Delete, Modify) however i do not know how to read the whole registry. I am looking for certain keys, but they end up being all over the place. I need to be able to identify their exact path. I am working in Windows Forms C# Thanks

    N 1 Reply Last reply
    0
    • O oskardiazdeleon

      I have been working with RegistryKeys (Create, Delete, Modify) however i do not know how to read the whole registry. I am looking for certain keys, but they end up being all over the place. I need to be able to identify their exact path. I am working in Windows Forms C# Thanks

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello

      oskardiazdeleon wrote:

      i do not know how to read the whole registry

      The registry is a tree of keys. The main 5 are present in the System.Win32.Registry Class. You can access them one by one using recursive calling to scan all subkeys but that will be very lenthy!!

      oskardiazdeleon wrote:

      I need to be able to identify their exact path.

      Be carful when -or if- you scan the registry of similar names. You should identify your key by its full name. Besides the registry structue is quite constant for a given windows version. What you are looking for will probably be in the same location on other machines running the same version.

      Regards:rose:

      O 1 Reply Last reply
      0
      • N Nader Elshehabi

        Hello

        oskardiazdeleon wrote:

        i do not know how to read the whole registry

        The registry is a tree of keys. The main 5 are present in the System.Win32.Registry Class. You can access them one by one using recursive calling to scan all subkeys but that will be very lenthy!!

        oskardiazdeleon wrote:

        I need to be able to identify their exact path.

        Be carful when -or if- you scan the registry of similar names. You should identify your key by its full name. Besides the registry structue is quite constant for a given windows version. What you are looking for will probably be in the same location on other machines running the same version.

        Regards:rose:

        O Offline
        O Offline
        oskardiazdeleon
        wrote on last edited by
        #3

        Thank you for replying. I appreciate you sharing your knowledge. Are there functions within the Registry class that would allow me to scan it? Im assuming i have to setup a while statement to read through each key within the the tree. Would you have any idea of how to start off the syntax? Thank you I appreciate your help

        N 1 Reply Last reply
        0
        • O oskardiazdeleon

          Thank you for replying. I appreciate you sharing your knowledge. Are there functions within the Registry class that would allow me to scan it? Im assuming i have to setup a while statement to read through each key within the the tree. Would you have any idea of how to start off the syntax? Thank you I appreciate your help

          N Offline
          N Offline
          Nader Elshehabi
          wrote on last edited by
          #4

          Hello Not a while loop. Here is a sample code of how to go through all keys in the registry using foreach loops and recursive function calling:

          private void ScanRegistry()
              {
                  RegistryKey Key;
                  //Do somehting with the main 5 keys
                  foreach (string subkey in Registry.ClassesRoot.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.CurrentConfig.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.CurrentUser.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.DynData.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.LocalMachine.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.PerformanceData.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
                  foreach (string subkey in Registry.Users.GetSubKeyNames())
                  {
                      Key = Registry.ClassesRoot.OpenSubKey(subkey);
                      MessageBox.Show(Key.Name);
                      //Do somehting with the key
                      ScanKey(Key);
                  }
              }
          
              private void ScanKey(RegistryKey Key)
              {
                  //Do somehting with the key
                  RegistryKey subKey;
                  foreach (string subkeyname in Key.GetSubKeyNames())
                  {
          
          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups