We write a simple program that writes text to the debugger, if any is attached.
The entry point of a Windows application is WinMain instead of the traditional main function.
int __stdcall WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
__stdcall is the calling convention that defines the order that parameters on the stack when the function is called.
<aside>
💡 On x64 processors, __stdcall is ignored by the compiler.
</aside>
The return value is the exit value for the application.
A return value of 0 indicates that the application executed successfully.
A handle to the instance of the application.
This parameter used to represent the handle to an existing application's instance in Windows 16-bit.
It is now deprecated and always set to null.
<aside>
📜 In Windows 16-bit, hPrevInstance could be checked to determine if the application was already running.
There are now different methods to detect whether an application is already running (using a mutex for example).
</aside>
The command-line arguments (excluding the program name).
A flag that indicate whether the main window should be minimized, maximized, or shown normally.
The value is used with ShowWindow and corresponds to the SW constants (SW_NORMAL).
<aside>
💡 The nCmdShow corresponds to the Run property of an application's shortcut.
</aside>

The property window for an application's shortcut
An application compiled as a Unicode program has an alternative entry point function called wWinMain that takes a Unicode lpCmdLine parameter to receive a Unicode version of the command-line arguments.
int __stdcall wWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PWSTR lpCmdLine,
int nCmdShow
);