How can I convert LPCWSTR to LPWSTR.
In one method I am getting an argument type as LPCWSTR. This parameter(LPCWSTR) has to be passed to another method of argument type LPWSTR.
Create a new string, copy the contents into it, and then call the function that expects a modifiable string:
LPCWSTR str = L"bar";
std::wstring tempStr(str);
foo(&tempStr[0]);
LPCWSTR is a pointer to a const string buffer. LPWSTR is a pointer to a non-const string buffer. Just create a new array of wchar_t and copy the contents of the LPCWSTR to it and use it in the function taking a LPWSTR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With