title: Visual C++ err: RegGetValueA could not be located
body: <p>Attempting to write a simple registry-check script in Visual Studio 2010, running on XP SP3 x86.</p>
  
  <p>No errs are thrown on build, but on debug the program exits with the following error:</p>
  
  <blockquote>
    <p>The procedure entry point RegGetValueA
    could not be located in the dynamic
    link library ADVAPI32.dll</p>
  </blockquote>
  
  <p>Here is the entire code of the program.</p>
  
  <pre><code>// #define _WIN32_WINNT 0x0501
  
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  
  int main(int argc, char *argv[])
  {
  long reg = RegQueryValueEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", NULL,NULL,NULL,NULL);
  // if (reg!=ERROR_SUCCESS) MessageBox(0, "Error Opening Registry Key", "Error", 0);
  return 0;
  }
  </code></pre>
  
  <p>The comments in the code above where added based on an answer by wmeyer.<br>
  When uncommented, the code does not exit with that error, but throws a different error:</p>
  
  <blockquote>
    <p>Debugging information for Test5.exe
    cannot be found or does not match.
    Binary was not built with debug
    information. Do you want to continue
    debugging?</p>
  </blockquote>
  
  <p>If I continue, the MessageBox pops up with "Error Opening Registry Key".</p>
  
  <p>I have tried replacing the RegQueryValueEx function with the following three other methods, one at a time.<br>
  I KNOW THAT TWO OF THEM ARE VISTA ONLY, but I wanted to see if the error would be different.<br>
  It wasn't.</p>
  
  <pre><code>long reg = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, hKey);
  
  // Vista+ PHKEY hKey;
  long reg = RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", hKey);
  long reg = RegGetValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "", RRF_RT_ANY, NULL, NULL,NULL);
  </code></pre>
  
  <p>I've already lost hours trying to work out several other errors, such as "cannot convert parameter 1 from 'char' to 'LPCWSTR'" - which was solved by <a href="https://stackoverflow.com/questions/3924926/cannot-convert-parameter-1-from-char-to-lpcwstr/3925049#3925049">changing the configuration</a>
  and "Cannot find or open the PDB file", solved by <a href="http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/f2d31010-dc89-4290-8869-11bf4a037ea0" rel="nofollow noreferrer">changing the configuration</a>.</p>
  
  <p>So again, the question to be clear:</p>
  
  <ol>
  <li>How do I deal with the error?</li>
  <li>How did wmeyer's suggestion of adding a header to filter out Vista-only methods help, when the prog has no Vista methods to begin with? And why does the program still not work?</li>
  </ol>
  
  <p>My computer definitely does have a advapi.dll file in Windows/syatem32.</p>
  
  <p>EDIT:
  Completely rewrote the question when the answers pointed out how unclear it was.<br>
  Originally I had assumed that Visual Studio 2010 is not backwards compatible with XP.<br>
  I've been forcefully told that is incorrect, but still can't get VS to work.</p>