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中没用宽字节

 

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2021-04-29
  • 2022-03-09
  • 2021-07-19
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案