I want to create a very simple background application. I start with the empty c++ project, and I create a source.cpp file with the code below:
#include "Windows.h"
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG Msg;
while (GetMessage(&Msg, NULL, 0, 0))
{
}
return 0;
}
then I set the settings of the project as follow:
Properties -> Configuration Properties -> Linker -> System: Set SubSystem is: Windows (/SUBSYSTEM:WINDOWS)
Properties -> Configuration Properties -> Linker -> Advanced ->Set Entry Point is: _tWinMain
Am I doing it right? Also I want to add the MFC library into this project so I can use the MFC's function, how can I do it?
Thanks for reading :)
Edit: Weird, I just need to include "tchar.h" and the error [ LNK1561: entry point must be defined ] disappear. I don't need to configure the project settings anymore. All I need is the code below:
#include "Windows.h"
#include "tchar.h"
int WINAPI _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
//MessageBox(0, _T("test"), _T("Test"), 0);
return 0;
}
_tWinMain, you are skipping required CRT startup code. This includes initializers for objects with static storage duration among others. If you want to understand how Windows processes work, read a book (like Windows Internals by Russinovich). Whatever you do, don't add MFC. It'll make it a lot harder to understand, what's going on. All the more, if you aren't proficient in C++, the Windows API or MFC.