MFC C3861 找不到标识符
我是搞C#的,刚接触VC++ 真的蒙圈了。。。请高手帮助
s2ws(s)报错,找不到标识符。
void CMFCApplication1Dlg::OnBnClickedButton1()//按钮
{
//string 转换为 LPCTSTR
string s = "aaa";
std::wstring stemp =s2ws(s); // Temporary buffer is required
LPCWSTR result = stemp.c_str();
//Button1 弹出窗口
MessageBox(result, _T("请进行判断"), MB_OK);
}
std::wstring s2ws(const std::string& s)
{
int len;
int slength = (int)s.length() + 1;
len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0);
wchar_t* buf = new wchar_t[len];
MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
std::wstring r(buf);
delete[] buf;
return r;
}