Registry Scan
-
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
-
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
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:
-
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:
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
-
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
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()) {