Every Windows application must have a WinMain function; like the main function of a standard C-language application, the WinMain function in effect serves as the entry point for your application. It contains statements and Windows functions that create windows and read and dispatch input intended for the application. The function definition has the following form:
int PASCAL WinMain(hinstCurrent, hinstPrevious, lpszCmdLine, nCmdShow)
HINSTANCE hinstCurrent;
HINSTANCE hinstPrevious;
LPSTR lpszCmdLine;
int nCmdShow;
{
.
.
.
}
Like all Windows functions, WinMain is declared with the PASCAL keyword. As a result, your definition of WinMain must contain all four parameters, even if your application does not use them all.
Even though Windows calls it directly, WinMain must not be declared with the FAR keyword or exported in the definition file, because it is called from startup code added by the linker to the same data segment. WinMain is implicitly declared NEAR or FAR, depending on the memory model that you use to compile the module that defines WinMain. This memory model must be consistent with the memory model of the C run-time link library containing the startup code that calls WinMain.