VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
来源:互联网 发布:汽车保险到期查询软件 编辑:程序博客网 时间:2024/04/28 05:50
问题:
1>d:\users\yangtse\documents\visual studio 2008\projects\winmain\winmain\54.cpp(27) : error C2440: “=”: 无法从“const char [14]”转换为“LPCWSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>d:\users\yangtse\documents\visual studio 2008\projects\winmain\winmain\54.cpp(35) : error C2664: “CreateWindowExW”: 不能将参数 2 从“const char [14]”转换为“LPCWSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
1>d:\users\yangtse\documents\visual studio 2008\projects\winmain\winmain\54.cpp(65) : error C2664: “MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”
1> 与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
解决:
MessageBox(hwnd,szChar,"char",0);
MessageBox 在2008中定义为 MessageBoxW W指的是宽字节(也叫UNICODE),有3种方法可解决
①用函数MessageBoxA
②在内容前加上TEXT(对变量无效),如MessageBox(hwnd,szChar,TEXT("char"),0);
③在项目属性->常规中,把Uicode改成多字符段。
PS:在2008中,很多函数的返回值都是宽字节的,所以不一定要用MessageBoxA
在MSDN上可以查到用宽字节的函数和同样功能普通函数的名称。
在6.0中没用宽字节
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- 关于vc6.0程序到vs2008下运行时的错误error C2664: “MessageBoxW”: 不能将参数 2 从“char *”转换为“LPCWSTR”
- c++问题之-- MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”
- VS2010 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- error C2664: “MessageBoxW”: 不能将参数 2 从“const char *”转换为“LPCWSTR”
- error C2664: “MessageBoxW”: 不能将参数 2 从“const char [10]”转换为“LPCWSTR”
- error C2664: “MessageBoxW”: 不能将参数 2 从“const char [36]”转换为“LPCWSTR”
- error c2664:"MessageBoxW":不能将参数2从“const char[15]”转换为“LPCWSTR”与指向的类型无关
- error C2664: MessageBoxW不能将参数2const char*转换为LPCWSTR的解决办法
- “error C2664: “MessageBoxW”: 不能将参数 2 从“char [300]”转换为“LPCWSTR” 1> 与指向的类型无关;转换要求 reinterpret_”问题解决
- VS2008下MessageBoxW出现不能将参数 1 从“const char [75]”转换为“LPCTSTR”
- 不能将参数 2 从“char [8]”转换为“LPCWSTR”
- 不能将参数 2 从“const char *”转换为“LPCWSTR” vs 2010解决
- VC“中 不能将参数 从“const char *”转换为“LPCWSTR” 的解决办法
- 不能将参数2从“const char[15]”转换为“LPCWSTR”与指向的类型无关
- 不能将参数 1 从const char [*]转换为LPCWSTR
- c++内存管理与指针的使用
- ubuntu 12.04安装 ia32-libs
- 数据结构回顾
- Eclipse无法自动弹出提示
- java.util.ConcurrentModificationException
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- EOF是什么?
- 寻找java应用的性能瓶颈----网络IO消耗分析
- Ubuntu 切换JDK 1.6、1.7
- codeforces 400A - Inna and Choose Options
- 辛辛苦苦写好的文章就这样没了
- php学习笔记(三)
- ubuntu开启SSH服务
- 2014年值得学习的js框架Angular.js