Try this:
- CHAR pString[] = "Hello world!";
-
WCHAR pWideString[80];
-
MultiByteToWideChar(CP_ACP,0,pString,-1,pWideString,80);
-
MessageBoxW(NULL, pWideString, TEXT(""), MB_OK);
All MessageBox does is call MessageBoxA or MessageBoxW.
All MessageBoxA does is convert your LPCTSTR string to a WCHAR string and then calls MessageBoxW.
That is, it is MessageBoxW that ios always called.
All this switching between ASCII and Unicode means switching your code between CHAR (char) and WCHAR (wchar_t) automatically. To help this out, Microsoft has developed the TCHAR system of macros. A TCHAR is a char when you are using ASCII (called multibyte by Microsoft) and a wchar_t when you are using Unicode.
The TCHAR equivalent of your code is:
- TCHAR pString[] = TEXT("Hello world!");
-
MessageBox(NULL, pString, TEXT(""), MB_OK);
Here the TEXT macro has properly converted your string.
You should be using only TCHAR and the TCHAR function mappings in your code. That is, you should not be using things like LPSTR in programs that need to run both multibyte and Unicode.
Considering that all new code need only run Unicode, use only WCHAR and MessageBoxW.