c++winapivisual-c++-2010

Cannot convert parameter from 'const char[20]' to 'LPCWSTR'


When compiling this code:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInsance,HINSTANCE hPrevInstance,PSTR cmdLine,int showCmd){
    MessageBox(0,"First Win32 Program","Window Tittle",MB_OK);
    }

I get the compiler error:

Error C2664: 'MessageBoxW': cannot convert parameter 2 from 'const char [20]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

What am I doing wrong?


Solution

  • You have UNICODE defined, so MessageBox is expecting a wide string.