After setting the character set in the project properties character set for multibyte character sets or Unicode raises two bugs, find the following information:
Workaround One:
The string that is usually entered manually is a const char* (that is, LPCSTR) type, so you simply change the messagebox in that sentence to MessageBoxA.
Workaround Two:
Parameters use the "_t" macro:
MessageBox (null,_t ("Open image failed!"), _t ("error"), MB_OK);
Or:
MessageBox (NULL, L "Openimage failed!", l "error", MB_OK);
/*
*************************************************************************************************************** *********************************
* When the project is a Unicode encoding, _t saves the string in parentheses in Unicode, and when the project is multibyte-encoded, _t the string in parentheses in ANSI mode
* The keyword "L", regardless of the encoding environment, is to save the string that follows it in Unicode mode.
*************************************************************************************************************** **********************************
*/
1. Replace Char with Thcar
2, String plus _t (""), such as _t ("Hello")
3, replace strcpy with _tcscpy, etc.
The ANSI operation functions start with STR, such as strcpy (), strcat (), strlen ();
The Unicode manipulation functions start with WCS, such as wcscpy,wcscpy (), wcslen ();
Ansi/unicode mutually compatible operation functions begin with _tcs _tcscpy (C run-time library);
Ansi/unicode mutually compatible operation functions begin with Lstr lstrcpy (Windows functions);
Considering ANSI and Unicode compatibility, you need to use a generic string manipulation function that begins with _tcs or LSTR.
Finally add header file #include <tchar.h>
Reference Link: Http://zhidao.baidu.com/question/327887942.html?qbl=relate_question_2&word=LPWSTR
How does the formal parameter type of the char type in VS LPCWSTR type not be compatible?