“=”: 无法从“const char”转换为“LPCWSTR”
1、用VS打开需要编译的代码

2、按下F7键编译代码时出现了错误提示:
error C2440: “=”: 无法从“const char [25]”转换为“LPCWSTR”

3、双击错误提示语句可以定位到出现错误的地方。如下图所示
wndClass.lpszClassName ="DIRECTX11BookWindowClass";

4、将鼠标悬停在错误提示的地方可以看到如下提示

5、将此句 wndClass.lpszClassName ="DIRECTX11BookWindowClass";
更改为wndClass.lpszClassName =L"DIRECTX11BookWindowClass";
即在字符串的前面添加一个大写L。
这样可以实现将字符串转换为宽字符集。

6、再次编译即可成功运行,若不能运行,请修改其他地方出现的错误。

阅读量:88
阅读量:92
阅读量:58
阅读量:159
阅读量:94