Can't convert from const char* to LPCWSTR --VS often encounters

mistake:

cannot convert from const char* to LPCWSTR

Projects compiled successfully in VC 6.0 often have this type of error in VS2005 vs2005, vs2008, vs2010.

Solution:

Method 1: The feasible way is to use _T ("TEST") conversion.

Another method is: project menu - project properties (last) - configuration properties - general - project defaults - character set, change the use of Unicode character set to not set.

reason:

This is due to a character encoding issue.

VC6 uses MBCS (multi-byte character set) encoding by default, while VS2010 and later versions of VS use Unicode encoding by default.

What is the difference between UNICODE and MBCS or ANSI?
Simply put, the UNICODE version of the character occupies more memory than ANSI. For example, the original standard definition char that appears in Win32 programs occupies one byte, while the UNICODE version of char occupies 2 bytes, which is defined as follows: typedef unsigned short wchar_t .

Reprinted from: https://www.cnblogs.com/dongsheng/p/3586418.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325699056&siteId=291194637