Cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'

对着背影说爱祢 提交于 2019-12-12 12:36:04

问题


I am getting this error:

cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'

With the code below. It is supposed to be C but at best visual studio 2012 offers an empty c++ project:

#include "windows.h"

int WINAPI WinMain (HINSTANCE hinst, HINSTANCE hprevinst, LPSTR cmdline, int showcmd)
{
    MessageBox(NULL, "Merhaba Dunya", "Merhaba", MB_OK);
    return 0;
}

What is incorrect?


回答1:


It seems your current settings are set up so that WinAPI functions expect wide strings:

MessageBox(NULL, L"Merhaba Dunya", L"Merhaba", MB_OK);



回答2:


Right click on your project, go to properties under configuration properties -> General and change character set to Use multi-byte character set.




回答3:


There steps below worked for me:

  1. Right click on your Project in Solution Window, then select Properties menu item.
  2. Click on General under "Configuration Properties" in Property Pages
  3. At "Character Set" setting: change "Use Unicode Character Set" to "Use Multi-Byte Character Set", then click on OK button
  4. Rebuild your project to see how it works


来源:https://stackoverflow.com/questions/15592906/cannot-convert-parameter-2-from-const-char-14-to-lpcwstr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!