LPCTSTR /Data Types/ cannot convert parameter 1 from 'const char [5]' to 'LPCTSTR'

LPCTSTR   A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.

CButton::Create

BOOL Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );

若:

CButton m_btn;

m_btn.Create("按钮",WS_CHILD|BS_DEFPUSHBUTTON,CRect(0,0,100,100),this,123);

提示:error C2664: 'CButton::Create' : cannot convert parameter 1 from 'const char [5]' to 'LPCTSTR'

修改:

m_btn.Create(L"按钮",WS_CHILD|BS_DEFPUSHBUTTON,CRect(0,0,100,100),this,123);

//把字符串 "按钮" 定义为宽字符串 L"按钮"

原文地址:https://www.cnblogs.com/ezhong/p/2171501.html