I just dont understand

Started to practicing C/C++ and so much anger.

This code

#include <windows.h>

int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "degvbty", "243434", MB_OK);
return 0;
}
it compiles nicely ( Visual Studio 2013 ULT ) but it does not start, in task manager i can see that some sort of loading occurred.
closed account (oGN8b7Xj)
Change "NULL" by "this"?
Last edited on
Are you sure it compiles ? Using default settings of VS2013 it doesn't, as UNICODE is automatically enabled.
As a prerequisite to any programming work one must first successfully graduate from a course in anger management :)

If you were using Code::Blocks instead of Visual Studio it would have worked.
Just go to project settings ->Configuration Properties->General->Character Set and set it to
Use Multi-Byte Character Set. When you run it you will see your message box.
Yes i did it in VS2013 and changed to MByte set and this code i used here was test code and test did not work more detailed problem description is it compiles nicely no error but if i start it nothing happens and i can see in taskmanager that software is running and nothing happening same software runned nicely 2+ years ago on windows 7 like im am traying to run it now. i hate writing stuff not in my native language.
What Windows Version do you use?

I use Win 7 and VS 2013 Community and it works fine.
Me to
Name Microsoft Windows 7 Ultimate
Version 6.1.7601 Service Pack 1 Build 7601

closed account (E0p9LyTq)
You have several options:

1. change the project's character set use in your project's properties/settings.

2. before including <windows.h> check if UNICODE has been defined and undefine it as needed:
1
2
3
4
5
6
#ifdef UNICODE
#undef UNICODE
#undef _UNICODE
#endif

#include <windows.h> 


3. prefix your string literals with L, the wchar_t character type specifier: MessageBox(NULL, L"degvbty", L"243434", MB_OK);
http://www.cplusplus.com/doc/tutorial/constants/


4. wrap your string literals with the TEXT() macro: MessageBox(NULL, TEXT("degvbty"), TEXT("243434"), MB_OK);
https://msdn.microsoft.com/en-us/library/windows/desktop/dd374074%28v=vs.85%29.aspx

I personally prefer #4 so I can compile source with any compiler that can create Windows apps, Visual Studio or GCC/MinGW. A side benefit is I can change the character set usage, UNICODE or ANSI, and the same source should compile without change.
for safety https://drive.google.com/file/d/0B4D6J_Jr9kJPbWJ5akU3ZnQxN2c/view?usp=sharing i give full code so you can compile it run it see it
closed account (E0p9LyTq)
You use unsafe CRT printf/sprintf functions. Consider replacing them with the StrSafe functions.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms647465%28v=vs.85%29.aspx
Topic archived. No new replies allowed.