Visual Studio 2010 is Unicode by default, and projects that are compiled successfully in VC 6.0 often have type errors in VS2010. The common error is that you cannot convert from const char * to LPCWSTR, such as using CreateDC ("display", null,null,null), if you use CAST (LPCWSTR) "Display", though you can pass, But the encoding will go wrong. The possible way is to use text ("display") to convert, CreateDC (text ("Display"), null,null,null); Another way is: the Project menu-project Properties (last)-Configuration properties-General-Project Default--character set, will use the Unicode character set instead of set.
Lpcwstr
MSDN Original:
An LPCWSTR was a 32-bit pointer to a constant string of 16-bit Unicode charactor, which could be null-terminated. This type is declared as Follows:typedef const wchar_t* LPCWSTR;
LPCWSTR is a 32-bit pointer to a Unicode-encoded string that is the WCHAR type, not the char type.
Because the encoding is Unicode by default after VS2005, some functions call the Unicode method (function name +w,exp:messagebox+w=messageboxw) instead of Asni mode (the function name +a,exp:) when used. MESSAGEBOX+A=MESSAGEBOXA).
If you encounter a parameter error (cannot convert parameter * from ' const char [* *] ' to ' LPCWSTR '), consider looking at the declaration, if there is a asni way, just add a A to the back of the function, or change char * to WCHAR * when defining parameters.
Reference Link: Http://baike.baidu.com/view/7716877.htm?fr=aladdin
vc++:char* or string converted to LPCWSTR