hi, how to convert LPCSTR to LPWSTR if UNICODE is #defined?
Thanks.
hi, how to convert LPCSTR to LPWSTR if UNICODE is #defined?
Thanks.
Depends on what you want to do.
Do you simply want to pass a string literal such as "Hello, this is my string"?
If so, append L: L"Hello, this is my string".
If you want to do a conversion, it's slightly more difficult. Let me know what you want to do.
or you can use TEXT macro - so your string literals will be converted automatically to the correct type depending on the defined/not defined UNICODE macro (or _UNICODE - I do not remember which...)
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
If you're not talking about a string literal......
Well, your subject says "LPCTSTR to LPWSTR" and your post says "LPCSTR to LPWSTR" - so I'll awnser both.
"LPCSTR to LPWSTR"
MultiByteToWideChar() or mbstowcs()
"LPCTSTR to LPWSTR"
ggCode:LPCTSTR tsz; LPWSTR wsz; #if defined(UNICODE) || defined(_UNICODE) wsz = tsz; // or lstrcpyW() or wcscpy() #else // MultiByteToWideChar() or mbstowcs() #endif