title: RegQueryValueEx - What code add to this function to show ERROR_SUCCESS
body: <p><strong>What code add to this function to work good? (ERROR_SUCCESS)</strong></p>
  
  <p>I have code, that check value in registry.</p>
  
  <p>In function <code>RegQueryValueEx</code> is bug.
  When <code>oldValue</code> is few letters longer than <code>newValue</code>, function shows <code>ERROR_MORE_DATA</code>, but I want want <code>ERROR_SUCCESS</code></p>
  
  <p>What code add to this function to do this?</p>
  
  <pre><code>void function(string newValue, string key, string name)
  
  {
  
   // string key - key in registry, ie Myapp\\Options
   // string name - name in registry
   // string newValue - data in REG_SZ
  
  
   string oldValue;
   DWORD keytype = REG_SZ;
      HKEY keyHandle;
   DWORD size = sizeof(string);
   if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, key.c_str(),0L,KEY_ALL_ACCESS,&amp;keyHandle) == ERROR_SUCCESS)
   {
  
  
    LONG isgood = RegQueryValueEx(keyHandle, name.c_str(), 0, &amp;keytype, (LPBYTE)&amp;oldValue, &amp;size);
    if(isgood == ERROR_MORE_DATA)
     {
      cout &lt;&lt; "Error more data\n"; 
     }
    if(isgood == ERROR_SUCCESS)
    {
     cout &lt;&lt; "Old data is " &lt;&lt; oldValue.c_str() &lt;&lt; endl;
     cout &lt;&lt; "New data is " &lt;&lt; newValue.c_str() &lt;&lt; endl;
     if(strcmp(newValue.c_str(), oldValue.c_str()) != 0) // compare 2 strings, if
     {
      cout &lt;&lt; "String 1 and string 2 are different";
  
     }
     else
     {
      cout &lt;&lt; "String 1 and string 2 are the same";
     }
    }
    if(isgood == ERROR_FILE_NOT_FOUND)
    {
     cout &lt;&lt; "Name in registry not found!";
    }
   }
  
  }
  </code></pre>