title: RegSetValueEx function writing gibberish
body: <p>I am using the RegSetValueEX in the following code and it is setting the value to incomprehensible chars (chinese looking). I'm guessing something with the whole beautiful world of encoding?</p>
  
  <pre><code>HKEY regKey;
  std::string newIP = "192.168.1.2";
  
  Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Comm\\VMINI1\\Parms\\TcpIp"), 0, 0, &amp;regKey);
  if (Result == ERROR_SUCCESS)
  {
      Result = RegSetValueEx(regKey, TEXT("IPAddress"), 0, REG_SZ, (const BYTE*)newIP.c_str(), newIP.size() + 1);
      if (Result == ERROR_SUCCESS)
      {
          std::cout &lt;&lt; "Done!";
      }
  }
  </code></pre>
  
  <p>When I look at the registry entry however, the ip address is not set to the value supplied, it is random characters. What could be the problem?</p>