title: Cannot Access Registry After Calling GetSubkeyNames()?
body: <p>I thought this was a security issue but after several tries, I am not sure anymore.</p>
  
  <p>I am trying to read subkey names, then read values from the subkeys but I get an 'Requested Registry Access not Allowed', yet the app is running as administrator. Below is my code:</p>
  
  <pre><code>RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4D36E96D-E325-11CE-BFC1-08002BE10318}");
  //string[] names = key.GetSubKeyNames(); //causes error at key.OpenSubkey below
  string[] names = new[] {"0000", "0001", "0002"};
  foreach (string name in names)
  {
      string fname =key.OpenSubKey(name).GetValue("FriendlyName").ToString();
      string port =key.OpenSubKey(name).GetValue("AttachedTo").ToString();
      listView1.Items.Add(new ListViewItem(new[] {name, fname, port}));
  }
  </code></pre>
  
  <p>What could be causing this? I tried closing the key but that only adds another trying to access closed key error.</p>