1. 程式人生 > >error C2664: “int CWnd::MessageBoxW(LPCTSTR,LPCTSTR,UINT)”: 無法將參數 1 從“const char [9]”轉換為“LPCTSTR”

error C2664: “int CWnd::MessageBoxW(LPCTSTR,LPCTSTR,UINT)”: 無法將參數 1 從“const char [9]”轉換為“LPCTSTR”

報錯 連接失敗 更新 vs2015 轉換 nbsp b-s ons code

error C2664: “int CWnd::MessageBoxW(LPCTSTR,LPCTSTR,UINT)”: 無法將參數 1 從“const char [9]”轉換為“LPCTSTR”

出現錯誤的語句 m_pdlg->MessageBox("連接失敗");

在VS2015上面上面的語句會報錯,但是在VC 6.0++ 沒有出現錯誤,出現這樣的錯誤主要是VC 6.0++是比較老的開發軟件了,隨著技術的更新,VS2015上面已經舍去了VC 6.0++上面的功能,解決的辦法主要有2種

第一種、將上面的語句改為m_pdlg->MessageBox(_T("連接失敗"));

第二種、在VS項目屬性->常規->字符集改為未設置,一般默認都是使用Unicode字符集

error C2664: “int CWnd::MessageBoxW(LPCTSTR,LPCTSTR,UINT)”: 無法將參數 1 從“const char [9]”轉換為“LPCTSTR”