title: RegQueryValueEx() always returns only 4 bytes of the string
body: <p>What im doing wrong this time? The following code always returns 4 bytes only, instead of the whole string:</p>
  
  <pre><code>HKEY hkey;
  DWORD dwType, dwSize;
  
  char keybuffer[512];
  
  if(RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("software\\company name\\game name"), 0, KEY_READ, &amp;hkey) == ERROR_SUCCESS){
      dwType = REG_SZ;
      dwSize = sizeof(keybuffer);
      RegQueryValueEx(hkey, TEXT("setting"), NULL, &amp;dwType, (PBYTE)&amp;keybuffer, &amp;dwSize);
      RegCloseKey(hkey);
  }
  </code></pre>
  
  <p>Even if i change dwSize to anything, it will still return 4 bytes.</p>
  
  <p><strong>Edit:</strong> Apparently there was no bug in above code, but somewhere else -_-</p>