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

标签 c visual-studio-2012 lpcwstr

我收到这个错误:

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

使用下面的代码。它应该是 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;
}

哪里不对?

最佳答案

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

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

关于无法将参数 2 从 'const char [14]' 转换为 'LPCWSTR',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15592906/

相关文章:

c - 为什么我的程序在输入 Enter 时停止工作?

c++ - 为什么 C-forkbombs 不像 bash 那样工作?

visual-studio - 在 Visual Studio 中,使用 Windows Azure 存储, "Remember Account Key"保存在哪里?

visual-studio - Visual Studio 本地工作区 + 启用 Nuget 包还原 (disableSourceControlIntegration)

css - 单选按钮周围的空间变大

c++ - 我是否正确地将 PCWSTR 指向字符串文字?

c - 使线程获得相等的时间片

CLion 中的当前目录

c++ - Visual Studio 2010 Arduino cpp 错误 : argument of type "char *" is incompatible with parameter of type "LPCWSTR"