Originally Posted by Lindley
The std::wstring class has a c_str() method which returns exactly this type. So, no problem there.
If it were a LPWSTR instead, (wchar_t*, no const) then the c_str() method would not be appropriate. However, there are still two appropriate options.
For any vector<T> v which is non-empty, &v[0] is a T* which represents the vector as an array. (Trying to access v[0] can cause a crash if v is empty.) Therefore, we can simply copy the std::wstring into a std::vector<wchar_t> and then pass it to the WinAPI function as such.