title: How to convert LPWSTR* (or WCHAR*) to LPWSTR
body: <p>I'm having a difficulty in converting a value to LPWSTR.  I'm getting a registry value, and trying to return the result as LPWSTR.  It appears the registry call using RegQueryValueExW works with a variety of types going in to store the result, but I can't cast any of them back to LPWSTR.</p>
  
  <pre><code>LPWSTR value;
  HKEY hKey;
  
  long result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"RegEntry1", 0, ACCESS|KEY_WOW64_32KEY, &amp;hKey); 
  if (result == ERROR_SUCCESS)
  {
     //WCHAR buffer[512];
     //TCHAR buffer[512];
     LPWSTR buffer[512];
     DWORD bufferSize = sizeof(buffer); 
     ULONG queryVal = 0; 
  
     queryVal = RegQueryValueExW(hKey, L"Path", 0, NULL, (LPBYTE)buffer, &amp;bufferSize); 
     if (queryVal == ERROR_SUCCESS)
     { 
        //Access violation error here; I need some type of conversion.
        value = buffer;
     }
  }
  </code></pre>
  
  <p>No posts that I've read on here so far have led me to an answer.  C++ is not my primary dev language.</p>
  
  <p>UPDATE:  None of the proposed answers worked for me.  I found an alternative way to do what I needed.</p>