VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
来源:互联网 发布:小白素材vip源码 编辑:程序博客网 时间:2024/04/30 10:21
转载自:http://blog.csdn.net/tangy110/article/details/6629682
问题:
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中没用宽字节
转载自:http://apps.hi.baidu.com/share/detail/16474815
- 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
- proc文件系统的理解
- Android中Service和IntentService使用区别
- HDU 4417 主席树
- 笔记本adb无线调试最简便的方法
- 【排序】快速排序
- VS2008中关于“MessageBoxW”: 不能将参数 2 从“char [20]”转换为“LPCWSTR”的错误解决
- 安装完最小化 RHEL/CentOS 7 后需要做的 30 件事情(一)
- ClassNotFoundException: org.apache.ws.commons.schema.resolver.URIResolver
- 删除jar包的某些class重新打jar包
- 常用控件的初始化
- ContentProvider基础
- C/C++ 关于大小端模式
- UVA1594
- 前端学习总结(十七)React Native——移动开发的未来趋势