Very Simple Win32 API Code! Weird Compiler Error Need to Be Fixed! Help

I have been trying to start learning Win32 API on GUI's. Eventhough my code is right, i keep getting compiler errors!

This my main code as you see it below.

When i compile it, i get this nonsense ***error:

c:\users\user\desktop\win32\mysource\ttt\ttt\ttt.cpp(5) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR'
 Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
 1>Build log was saved at "file://c:\Users\user\Desktop\Win32\mySource\ttt\ttt\Debug\BuildLog.htm"
 ttt - 1 error(s), 0 warning(s)

However, i fixed it, i had to do something with Unicode in the config. box

I compile the program again, i get ***error that says my code does not include #include"stdafx.h", or something similar.

I added #include "stdafx.h" at the top. I recompiled, i get this ***error:

c:\users\user\desktop\win32\mysource\ttt\ttt\ttt.cpp(2) : fatal error C1083: Cannot open precompiled header file: 'Debug\ttt.pch': No such file or directory
. Build log was saved at "file://c:\Users\user\Desktop\Win32\mySource\ttt\ttt\Debug\BuildLog.htm"

NOTE: my vista got too many problems, many lost system files. Every time, i open VC++ Express
i get this error below:

The Visual Studio Debugger ({C9DD4A57-47FB-11D2-83E7-00C04F9902C1}) did not load because of previous errors. For assistance, contact the package vendor. To attempt to load this package again, type 'VCExpress /resetskippkgs' at the command prompt

Anyhow, i think this one of the reasons why my code does not compile, but i found many people face same 3 errors i mentioned above.

Can you help please?

Extra question: Does VC++ Express (Free version) support Win32 API & MFC fully?

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR IpCmdLine, int nCmdShow)
	MessageBox(NULL, "Hey", "NOTE", MB_OK);
	return 0;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. Unicode :
use _T("mytext") instead of "mytext" everywhere you want to use static text.

2. PreCompiled Header
You can remove precompiled headers for a cpp files separately. Right click on you cpp file and choose Properties. Go to C/C++-> Precompiled Headers in the thread and deactivate it.
As far as I know, a new project should be built at least once without moditication. If this problem persist maybe files could not be written to disk?

3. Package Error. I don't have Express version. But imo you should de- and reinstall the product. If you seriously damaged your Windows you also should consider to reinstall it. You properly will get more errors in different applications.

4. MFC/API is supported fully imo.
evilrixSenior Software Engineer (Avast)Commented:
>> : cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR'
Microsoft insist on using a compile time macro to switch their API between narrow and wide support (for some reason they also insist on referring to wide as Unicode, when it is not. Unicode is a character encoding and has nothing to do with wide or narrow, you can represent Unicode in either 8, 16 or 32 bit data types so why they insist on confusing everyone is beyond me). As CW (above) has pointed out, literal strings should be wrapped withe the _T() macro so they are correctly represented as narrow or wide according to the compile time setting. Also, rather than using char or wchar_t if you stick with TCHAR this'll be either a narrow or wide type according, also, to the compile time setting.

>> error that says my code does not include #include"stdafx.h", or something similar.
If you are building with precompile headers enabled you need to ensure you include stdafx.h in all your .c/.cpp files. Alternatively, and what I normally do, just turn of precompiled headers in the project settings. They really don't provide much in the way of benefit unless (a) you are building lots of code and (b) you have structured your code to make good use of them.

>> my vista got too many problems, many lost system files. Every time, i open VC++ Express
A standard install of VC++ Express is not compatible with Vista. There is a Vista specific service pack you need to apply.

>> Does VC++ Express (Free version) support Win32 API & MFC fully?
Win32 API: of course ---> what do you think MessageBox() is? :)
MFC : No and for that we are truly grateful! Try looking at the superior (???) Windows Forms (look in the new projects menu)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
F-J-KAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.