cannot convert parameter 2 from 'WORD' to 'LPCWSTR'
来源:互联网 发布:sha256算法详细 编辑:程序博客网 时间:2024/06/05 02:39
Resolution
You will have to do one of two things:
1、Change your project configuration to use multibyte strings. Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to "Use Multi-Byte Character Set".
2、Indicate that the string literal, in this case "Hello world!" is of a specific encoding. This can be done through either prefixing it with L, such as L"Hello world!", or surrounding it with the generic _T("Hello world!") macro. The latter will expand to the L prefix if you are compiling for unicode (see #1), and nothing (indicating multi-byte) otherwise.
Variations
Another error message, indicating the same problem, would be:
cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR' Where LPCWSTR maps to a wchar_t pointer, regardless of your build configuration. This problem can be resolved primarily by using solution #2, but in some cases also #1. A lot of the Microsoft provided libraries, such as the Platform SDK, have got two variations of each function which takes strings as parameters. In case of a unicode build, the actual functions are postfixed W, such as the MessageBoxW seen above. In case of multi-byte, the function would be MessageBoxA (ASCII). Which of these functions is actually used when you compile your application, depends on the setting described in resolution #1 above.
You will have to do one of two things:
1、Change your project configuration to use multibyte strings. Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to "Use Multi-Byte Character Set".
2、Indicate that the string literal, in this case "Hello world!" is of a specific encoding. This can be done through either prefixing it with L, such as L"Hello world!", or surrounding it with the generic _T("Hello world!") macro. The latter will expand to the L prefix if you are compiling for unicode (see #1), and nothing (indicating multi-byte) otherwise.
Variations
Another error message, indicating the same problem, would be:
cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR' Where LPCWSTR maps to a wchar_t pointer, regardless of your build configuration. This problem can be resolved primarily by using solution #2, but in some cases also #1. A lot of the Microsoft provided libraries, such as the Platform SDK, have got two variations of each function which takes strings as parameters. In case of a unicode build, the actual functions are postfixed W, such as the MessageBoxW seen above. In case of multi-byte, the function would be MessageBoxA (ASCII). Which of these functions is actually used when you compile your application, depends on the setting described in resolution #1 above.
阅读全文
0 0
- cannot convert parameter 2 from 'WORD' to 'LPCWSTR'
- VS2008中报错:cannot convert parameter 2 from 'char *' to 'LPCWSTR'
- VS2005中报错:cannot convert parameter 2 from 'char *' to 'LPCWSTR'
- cannot convert parameter 2 from 'const char [12]' to 'LPCWSTR'
- cannot convert parameter 1 from 'const char *' to 'LPCWSTR
- cannot convert parameter 1 from 'char *' to 'LPCWSTR'
- VS2010 cannot convert parameter 1 from 'char *' to 'LPCWSTR'
- error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [2]' to 'LPCWSTR'
- 关于VS2005的error C2664: cannot convert parameter 2 from 'const char [2]' to 'LPCWSTR
- error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR' 原因
- error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR' 原因
- error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'char [20]' to 'LPCWSTR' 原因
- error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [16]' to 'LPCWSTR'
- error C2664: 'TextOutW' : cannot convert parameter 4 from 'const char [5]' to 'LPCWSTR'
- 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
- 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' 解决方案
- 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' 解决方案
- 'CreateFileW' : cannot convert parameter 1 from 'const char [13]' to 'LPCWSTR'
- 考试相关题目
- linux驱动开发--定时器
- Android studio 3.0 版本的出现的bug的总结
- Python数据分析入门-Pandas环境搭建
- iOS开发常用函数
- cannot convert parameter 2 from 'WORD' to 'LPCWSTR'
- 如何判断是客户端问题还是服务器问题
- ssd_pascal.py部分源码阅读
- 文章标题
- 在IntelliJ IDEA中使用maven jetty启动服务时,指定端口号
- Eclipse 4.7(Oxygen)
- 单元测试--Junit
- Docker认识、安装及使用(windows7)
- 最火的前端开发框架Bootstrap使用教程