Tag Archives: Visual Studio debugging related

Error C2664 in C + + compilation: cannot convert parameter 2 from “const char [5]” to “lpctstr” solution.

Reason: An error occurred while compiling the program due to setting the character set Unicode property when creating an MFC project
Solution 1:
In the VS Solution Manager window, right-click your project “Project”, then select “Properties” (the last item), click “Configuration Properties”, a + sign, expand it, then select the “General” TAB, the penultimate “Character set”, and select “Use multi-byte Character Set”. Problem solving.
Solution 2:

Use the call CString::AllocSysString();
Such as:
CString str_cap(“haha”);
(const WCHAR *) (str_cap. AllocSysString ()); .
(LPCTSTR) (str_cap AllocSysString ()); Same as above link:
Click on the open link