Note that there are some explanatory texts on larger screens.

plurals
  1. POIterating Registry, looking for Values
    primarykey
    data
    text
    <p>Scenario : We do not care about Performance. We have an Array of Values that we need to check for in the registry. //The Values can have anything infront of them. We need to change this.</p> <p>Right now, I don't feel like it itterates all the Values, it's like it skips a few and in the end becomes null and crashes.</p> <p>This is a console Program, Main looks like this :</p> <pre><code>static void Main(string[] args) { string[] FASKeyWords = new string[] { "DummyValue1", "DummyValue2" }; RegistryKey BaseKey = Registry.LocalMachine; foreach (string FASKeyWord in FASKeyWords) { Console.WriteLine("Looking in " + BaseKey.Name); Console.WriteLine("Looking for : " + FASKeyWord); GetSubKeys(BaseKey, FASKeyWord); } } </code></pre> <p>Now, Main calls this Void</p> <pre><code>private static void GetSubKeys(RegistryKey SubKey,string KeyWord) { foreach (string valueName in SubKey.GetValueNames()) { string Value = SubKey.GetValue(valueName).ToString(); //Check for any values at all. MessageBox.Show(valueName + " with data : " + Value); if (Value.Contains(KeyWord)) MessageBox.Show("Found '" + KeyWord + "' At " + SubKey.Name); } foreach (string Key in SubKey.GetSubKeyNames()) { MessageBox.Show(SubKey.Name); GetSubKeys(SubKey.OpenSubKey(Key), KeyWord); } } </code></pre> <p>I'm far from the best working with the Registry class, but to my knowledge this should be okay right? , I've been starring blindly at it for far too long now, I figured it would be good with another pair of eyes :)</p> <p>The Crash happens at : string Value = SubKey.GetValue(valueName).ToString(); with a NullReferenceException In Addition it does not Show a messageBox with all the Values inside a Key, It's like it just picks em out randomly.</p> <p>A visual on the problem. <a href="http://peecee.dk/uploads/122012/Untitled2.png" rel="nofollow">http://peecee.dk/uploads/122012/Untitled2.png</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload