Reputation: 8941
How to Convert TCHAR to LPWSTR in VC++ ?
Ex: I have
TCHAR achValue[16383];
I want assign this value to LPWSTR . How to achieve that in VC++
Any help is appreciated.
Upvotes: 3
Views: 11232
Reputation: 15870
You will need to set up a #ifdef
'd section to handle both cases: One for if UNICODE is defined (meaning TCHAR
is defined as wchar_t
) and the other for when it isn't defined (and you'll have to use MultiByteToWideChar
to convert it).
Upvotes: 0
Reputation: 91320
TCHAR
is either char
or wchar
_t based on your projects Unicode/MBCS setting. If you're compiling as unicode, achValue
can be used as a LPWSTR
. If not, you need to use MultiByteToWideChar
in order to convert the characters in achValue
from the encoding you use to UTF-16.
Upvotes: 4
Reputation: 73493
If your project file has UNICODE
flag defined, then you can simply do LPWSTR p = achValue;
Upvotes: 0