title: C++ read registry string value in char*
body: <p>I'm reading a registry value like this:</p>
  
  <pre><code>char mydata[2048];
  DWORD dataLength = sizeof(mydata);
  DWORD dwType = REG_SZ;
  
  ..... open key, etc
  ReqQueryValueEx(hKey, keyName, 0, &amp;dwType, (BYTE*)mydata, &amp;dataLength);
  </code></pre>
  
  <p>My problem is, that after this, mydata content looks like: [63, 00, 3A, 00, 5C, 00...], i.e. this looks like a unicode?!?!.</p>
  
  <p>I need to convert this somehow to be a normal char array, without these [00], as they fail a simple logging function I have. I.e. if I call like this: WriteMessage(mydata), it outputs only "c", which is the first char in the registry. I have calls to this logging function all over the place, so I'd better of not modify it, but somehow "fix" the registry value. Here is the log function:</p>
  
  <pre><code>void Logger::WriteMessage(const char *msg)
  {
   time_t now = time(0);
   struct tm* tm = localtime(&amp;now);
   std::ofstream logFile;
  
   logFile.open(filename, std::ios::out | std::ios::app);
  
   if ( logFile.is_open() )
   {
    logFile &lt;&lt; tm-&gt;tm_mon &lt;&lt; '/' &lt;&lt; tm-&gt;tm_mday &lt;&lt; '/' &lt;&lt; tm-&gt;tm_year &lt;&lt; ' ';
    logFile &lt;&lt; tm-&gt;tm_hour &lt;&lt; ':' &lt;&lt; tm-&gt;tm_min &lt;&lt; ':' &lt;&lt; tm-&gt;tm_sec &lt;&lt; "&gt; ";
    logFile &lt;&lt; msg &lt;&lt; "\n";
    logFile.close();
   }
  }
  </code></pre>