I wrote a program that displays Hello World in the MessageBox window. Compiled in MSVS 2008, but derived some Japanese, or Chinese characters (literally). What could be the problem:
#include<windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, (LPCWSTR) "Hello, World!!!", (LPCWSTR) "Hello from MessageBox", MB_OK); return 0; }
(LPCWSTR)
. No need to use explicit C-type casting. With this, you just gag the compiler, which would clearly curse that cannot char [] to wchar_t *. As correctly noted, it is better to use the _T macro and the TCHAR type to write portable programs. Another option is to use CString, which can be converted where necessary (although you need to carefully handle the built-in buffer). - gecube 3:12 pm