title: How to know why GetPrivateProfileInt/String fail
body: <p>I am working on a piece of code in the old application, using C++ in Visual Studio 2008. It attempts to read some values from an INI file, and I'm trying to do some error handling in the case of the section or key I am trying to read does not exist in the file. </p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>int nValue = GetPrivateProfileInt (SECTION, KEY, -1, sINIFile);
  if(nValue == -1)  // default value
  {
      int nLastError = GetLastError();
      if(nLastError != 0)
      {
          // do something
      }
  }
  </code></pre>
  
  <p>sINIFile contains the full path to my required INI file.</p>
  
  <p>After some testing, I've found that GetLastError() returns 2 (ERROR_FILE_NOT_FOUND) if:</p>
  
  <ol>
  <li><p>the file doesn't exist OR,</p></li>
  <li><p>the section doesn't exist OR,</p></li>
  <li><p>the key doesn't exist. </p></li>
  </ol>
  
  <p>I would like to know the specific reason the GetPrivateProfileInt returned the default value - is this possible?</p>
  
  <p>Note: I've looked into checking the value of 'errno' (or errorno, as it says on the MSDN page) but this is always 0 for any of the above cases. </p>