title: Cannot read Registry entry in C++
body: <p>I have a registry entry I can't seem to read in C++, but it shows up in <code>Regedit</code>.</p>
  
  <p>Using the following C++ snippet:</p>
  
  <pre><code>openResult=RegOpenKeyEx( HKEY_LOCAL_MACHINE, _TEXT("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"), 0, KEY_READ, &amp;root);
  readResult1=RegQueryValueEx(root, _TEXT("InstallPath"), NULL, NULL, data1, &amp;size);
  readResult2=RegQueryValueEx(root, _TEXT("fake_entry"), NULL, NULL, data2, &amp;size);
  </code></pre>
  
  <p>I get Error 2, <code>ERROR_FILE_NOT_FOUND</code> for my second <code>RegQueryValueEx()</code> call.</p>
  
  <p>As you can see in the image below, my <code>fake_entry</code> exists.</p>
  
  <p><img src="https://i.stack.imgur.com/QfjKH.png" alt="enter image description here"></p>
  
  <p>I created this entry via <code>Regedit</code>.</p>
  
  <p>Microsoft's <a href="http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx" rel="nofollow noreferrer">Registry Keys Affected by WOW64</a> does not include the location I'm trying to read, and as you can see in the picture below, my <code>fake_entry</code> is not in the <code>Wow6432Node</code> location.</p>
  
  <p><img src="https://i.stack.imgur.com/ApJvP.png" alt="enter image description here"></p>
  
  <ul>
  <li>Yes, I understand this isn't a registry location I should be changing. I stumbled upon this as I was debugging my code and am curious why my added <code>fake_entry</code> doesn't work.</li>
  <li>Yes, I've read about <a href="http://msdn.microsoft.com/en-us/library/aa384232%28v=VS.85%29.aspx" rel="nofollow noreferrer">Registry Redirector</a>. </li>
  <li>Yes, I've read <a href="https://stackoverflow.com/questions/7612992/unable-to-read-certain-registry-keys-in-c">this question</a>.</li>
  <li>Yes, I tried reading <code>fake_entry</code> at <code>SOFTWARE\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full</code> with the same error.</li>
  </ul>
  
  <p>Running Windows 7, 64 bit, C++ in Visual Studio 2010, using ASCII character encoding.</p>
  
  <p>Am I misunderstanding the Registry Redirector?
  Is there a problem with my code?
  Are there some sort of permission settings on certain portions of the Registry? I'm obviously missing something. Please point me in the right direction.</p>