WinMain is the main program in Windows. Windows passed in 4 parameter when WinMain starts - Instance handle (type HINSTANCE), Previous instance handle (HINSTANCE), a pointer to the command line string (LPTSTR) and the options for the window to be created (INT).
the first step is to register the window calling RegisterClassEx with a WINCLASSEX structure. The structure contains parameter about the main window to be created like if it is to be redrawn when the window is resized horizontally or vertically, the program instance, pointer to the window's call back function, pointer to the icon and mouse etc. The system call returns an integer - 0 if error and non-zero if ok.
The WinMain calls CreateWindow function to create the first window. It passes information about the window to be created like the title string, window style (e.g. overlapping), size and the application instance handle. CreateWindow returns a handle to a HWD structure.
At this point, the window is still not visible, WinMain calls ShowWindow and UpdateWindow, passing the HWND handle to draws the window.
This complete the initialization. WinMain then goes into a message loop to listen for messages to process. It calls GetMessage which will block the program until a message come in. It then call TranslateMessage and DispatchMassage which passes the message to the call back function to process.