0

Okay, this just makes me feel stupid. I'm pretty good at programming for the console so I figured I would try a Win32 program. Apparently I'm stupid because I cannot even compile hello world. Heres the code I copy and pasted.

#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	
	MessageBox(NULL, "\tHello World!", "My first windows app", NULL);
	return 0;
}

I'm getting this error twice:

argument of type "const char *" is incompatible with parameter of type "LPCWSTR"


Can anyone help me get this working? I already tried google.

5
Contributors
5
Replies
11
Views
6 Years
Discussion Span
Last Post by wade2462
Featured Replies
  • 1

    [QUOTE=wade2462]argument of type "const char *" is incompatible with parameter of type "LPCWSTR"[/QUOTE] See this codeproject article [URL="http://web1.codeproject.com/Tips/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc.aspx"]What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR etc?[/URL] Read More

1

I believe you need to change, in your project settings, that you're using a multi-byte character set instead of Unicode. That should solve your problem.

0
MessageBox(NULL, "\tHello World!", "My first windows app", NULL);

Change to

MessageBox(NULL, L"\tHello World!", L"My first windows app", NULL);
0

I believe you need to change, in your project settings, that you're using a multi-byte character set instead of Unicode. That should solve your problem.

Thank you this worked. Now I'm off to learn.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.