How do i convert const char * to LPCWSTR?
conversion from const char * to LPCWSTR
Collapse
X
-
-
This can be done several ways:
[code=cpp]
const char* c = "Hello";
LPCWSTR str = TEXT("Hello");
LPCWSTR str1 = L"Hello";
LPCWSTR str2 = _T("Hello");
WCHAR str3[6];
MultiByteToWide Char( 0,0, c, 5, str3, 6);
LPCWSTR cstr4 = str3;
[/code]
Read this:
http://msdn.microsoft. com/en-us/library/cc500362.aspx -
Originally posted by weaknessforcatsThis can be done several ways:
[code=cpp]
const char* c = "Hello";
LPCWSTR str = TEXT("Hello");
LPCWSTR str1 = L"Hello";
LPCWSTR str2 = _T("Hello");
WCHAR str3[6];
MultiByteToWide Char( 0,0, c, 5, str3, 6);
LPCWSTR cstr4 = str3;
[/code]
Read this:
http://msdn.microsoft. com/en-us/library/cc500362.aspx
Thanks for help it work properlyComment
-
Hi.
I'm developing a small aplication for pocket pc and I have the same exception :
"cannot convert parameter 1 from 'const char *' to 'LPCWSTR' "
But i can't solve in this way.
I should know how to solve it... but i'm beginer in the language...
I can't use the functions... because i have the string in a variable (var)
Somebody can help me??Comment
-
Simple Solution
I'm assuming your using Visual Studio.
The easiest solution to this problem is to change your solution settings from Unicode to Multi-btye.
VS sets windows applications to default to unicode. While unicode "may" be better, it certainly is more difficult for beginning programming and requires explicit conversions.
Right click on your Project, select Properties. Configuration Properties/General
And Character Set to Multi-Byte.Comment
Comment