error C2664: “CWnd::MessageBoxW”: 不能将参数 1 从“char *”转换为“LPCTSTR”
来源:百度知道 编辑:UC知道 时间:2024/05/21 17:34:00
void CFileproView::OnFileRead()
{
CFileDialog fileDlg(TRUE);
fileDlg.m_ofn.lpstrTitle=_T("我的文件打开对话框");
fileDlg.m_ofn.lpstrFilter=_T("Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0\0");
if(IDOK==fileDlg.DoModal())
{
CFile file(fileDlg.GetFileName(),CFile::modeRead);
char *pBuf;
DWORD dwFileLen;
dwFileLen=file.GetLength();
pBuf=new char[dwFileLen+1];
pBuf[dwFileLen]=0;
file.Read(pBuf,dwFileLen);
file.Close();
MessageBox(pBuf);
}
}
最后的MessageBox(pBuf);
提示上述错误,怎么修改啊,为什么啊
{
CFileDialog fileDlg(TRUE);
fileDlg.m_ofn.lpstrTitle=_T("我的文件打开对话框");
fileDlg.m_ofn.lpstrFilter=_T("Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0\0");
if(IDOK==fileDlg.DoModal())
{
CFile file(fileDlg.GetFileName(),CFile::modeRead);
char *pBuf;
DWORD dwFileLen;
dwFileLen=file.GetLength();
pBuf=new char[dwFileLen+1];
pBuf[dwFileLen]=0;
file.Read(pBuf,dwFileLen);
file.Close();
MessageBox(pBuf);
}
}
最后的MessageBox(pBuf);
提示上述错误,怎么修改啊,为什么啊
MessageBox 在2005中定义为 MessageBoxW W指的是宽字节(也叫UNICODE),有两种方法可解决
①用函数MessageBoxA
②在内容前加上TEXT(对变量无效),如MessageBox(TEXT("123"));
PS:在2005中,很多函数的返回值都是宽字节的,所以不一定要用MessageBoxA
在MSDN上可以查到用宽字节的函数和同样功能普通函数的名称。
在6.0中没用宽字节
不想回答你的问题,但给你个建议,把你的vs2005卸了换vs2008吧,速度快好多,另外升到sp1还有新的界面库,做出来的mfc程序界面很漂亮!
在项目属性->常规中,把Uicode改成多字符段。
改为
CString str;
str.Format(_T("%s"),pBuf);
MessageBox(str);
编译错误:error C2664 在VC++.net里使用DirectX9.0c
为什么会出现error C2664: 'f' : cannot convert parameter 1 from 'int' to 'int [][3]'
error:rumtime error 204 at 0040249C
C语言declaration syntax error
Data error reading drive C
C程序出错:error C2059: syntax error : '{'
c语言问题:error C2059: syntax error : ']'
倾家荡产求助:“C语言 declaration syntax error”
Ruantime error 183 at 0440385C
Data error reading drive C.是什么意思?