The WinMain function
In the Win32 API, WinMain
is the function equivalent to main
. Each application must include the definition of the WinMain
function. In order for Small Windows to work, WinMain
is implemented as a part of Small Windows, while MainWindow
has to be implemented by the user of Small Windows for each project. To sum it up, here are the three kinds of main functions:
Regular C/C++ |
Win32 API |
Small Windows |
main |
WinMain |
MainWindow |
The WinMain
function is called by the Windows system and takes the following parameters:
instanceHandle
: This holds the handle of the applicationprevInstanceHandle
: This is present due to backward compatibility but is alwaysnull
commandLine
: This is a null-terminated character (char
, notTCHAR
) array holding the arguments for the application, separated by spacescommandShow
: This holds the preferred appearance of the main window
WinMain.cpp
#include "SmallWindows.h" int WINAPI WinMain(HINSTANCE instanceHandle, ...