无法将参数 2 从“const char [14]”转换为“LPCWSTR”

Mon*_*RPG 3 c visual-studio-2012 lpcwstr

我收到此错误:

cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
Run Code Online (Sandbox Code Playgroud)

用下面的代码。它应该是 C 语言,但最好的 Visual Studio 2012 提供了一个空的 C++ 项目:

#include "windows.h"

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

什么是不正确的?

小智 6

右键单击您的项目,转到配置属性 -> 常规下的属性,并将字符集更改为使用多字节字符集。


小智 5

看来您当前的设置已设置为 WinAPI 函数需要宽字符串:

MessageBox(NULL, L"Merhaba Dunya", L"Merhaba", MB_OK);
Run Code Online (Sandbox Code Playgroud)