I found a very old post, which gives the answer as:
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.
I think I understand the first part - create a new array of wchar_t
and copy the contents of the LPCWSTR
to it.
wstring wstrSrc(myString.begin(), myString.end());
const int lngth = sizeof(wstrSrc) / sizeof(int);
PCWSTR str2PCWSTR = wstrSrc.c_str();
const wchar_t* filepath[lngth]{ str2PCWSTR };
However, I am not sure how to do the second part - use it in the function taking a LPWSTR
.
How do I use the contents of the wchar_t
array in a PWSTR
?
I tried searching for a clearer answer to the one I found, and tried, or made an effort to understand the suggestion.
I have not gotten any further than the code above.