title: How to pass std::string value to RegSetValueEx() in C++
body: <p>I am writing a program to edit the windows registry key by C++, but when I try to pass a string value to library function RegSetValueEx(), there is a file start with TEXT() which could only be hardcode value in it.</p>
  
  <p>Parts of my code:</p>
  
  <pre><code>string region;
  string excelserver_type;
  string keyname = region + excelserver_type;
  
  if (RegSetValueEx(key64, TEXT("XXXXXXXXX"), 0, REG_SZ, (LPBYTE)TEXT("XXXXXXXXXX"), 100) != ERROR_SUCCESS)
  
  {
              RegCloseKey(key);
              cout &lt;&lt; "Unable to set registry value in HKEY_LOCAL_MACHINE\\Software" &lt;&lt; endl;
          }
  </code></pre>
  
  <p>When I try to replace "XXXXXXXX" by keyname, it gives me an error. How do I pass value of keyname in RegSetValueEx()?</p>