Search code examples
cvisual-studio-2012lpcwstr

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


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?


Solution

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

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