The problem is the syntax for a string literal. The type
WCHAR
is the character type
wchar_t
; the string literal for this type should be prefixed with "L":
WCHAR string[] = L"MyWideCharString";
[EDIT]
You can also use
portable declaration style:
_TCHAR string[] = _T("MyWideCharString");
Here,
_TCHAR
and
_T
are just macro which works depending the definition of
_UNICODE
. They make type declaration either
char
or
w_char
and the string literal either L-prefixed or not, which allows you to switch from non-Unicode (ANSI) to Unicode version of the same code. This way, the type declarations and string literal using the macro remain consistent in either case.
See
http://msdn.microsoft.com/en-us/library/dybsewaf(v=VS.100).aspx[
^].
Null-terminated portable string types based on
_TCHAR
are
LPTSTR
and
LPCTSTR
, see
http://stackoverflow.com/questions/321413/lpcstr-lpctstr-and-lptstr[
^].
—SA