I am learning how to make Windows in C++, and I have a problem:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nShowCmd)
{
    MessageBox(NULL,
               L"Hello World!",
               L"TEST",
               MB_ICONEXCLAMATION | MB_OK);
	return 0;
}

I get this error: Error 1 error C2664: 'MessageBoxA' : cannot convert parameter 2 from 'const wchar_t [13]' to 'LPCSTR' 12

Your code should be:

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance,
				   HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine,
				   int nShowCmd)
{
    MessageBox(NULL, "Hello World!",
               "TEST",
               MB_ICONEXCLAMATION | MB_OK);
	return 0;
}

Your problem was on lines 8, and 9 :)

Works just right! Thanks for your help! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.