error C2664

来源:互联网 发布:最好的网络在线投资 编辑:程序博客网 时间:2024/05/16 00:59

 error C2664: ‘MessageBoxW’ : cannot convert parameter 2 from ‘const char *’ to ‘LPCWSTR’ Types pointed to are unrelated;conversion requires reinterpret_cast, C-style cast orfunction-style cast

 

 

 

这个错误困扰勒我好久

 

 

错误的原因只是由于编译器缺省打开UNICODE选项,而上面代码中MessageBox的第二个参数取的是ANSI的字符串,所以出错.


解决办法是:在工程属性设置页面里,在General选项中,将CharSet设置为Use Multi-Byte Character

 

重新编译,通过

原创粉丝点击