WinMain

  int WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)    
  HANDLE hInstance; /* handle of current instance */
  HANDLE hPrevInstance; /* handle of previous instance */
  LPSTR lpszCmdLine; /* address of command line */
  int nCmdShow; /* show-window type (open/icon) */

The WinMain function is called by the system as the initial entry point for a Windows application.

Parameters

hInstance

Identifies the current instance of the application.

hPrevInstance

Identifies the previous instance of the application.

lpszCmdLine

Points to a null-terminated string specifying the command line for the application.

nCmdShow

Specifies how the window is to be shown. This parameter can be one of the following values:

Value Meaning

SW_HIDE  
  Hides the window and passes activation to another window.
SW_MINIMIZE  
  Minimizes the specified window and activates the top-level window in the system's list.
SW_RESTORE  
  Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as SW_SHOWNORMAL).
SW_SHOW  
  Activates a window and displays it in its current size and position.
SW_SHOWMAXIMIZED  
  Activates a window and displays it as a maximized window.
SW_SHOWMINIMIZED  
  Activates a window and displays it as an icon.
SW_SHOWMINNOACTIVE  
  Displays a window as an icon. The window that is currently active remains active.
SW_SHOWNA  
  Displays a window in its current state. The window that is currently active remains active.
SW_SHOWNOACTIVATE  
  Displays a window in its most recent size and position. The window that is currently active remains active.
SW_SHOWNORMAL  
  Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position (same as SW_RESTORE).

Return Value

The return value is the return value of the PostQuitMessage function if the function is successful. This function returns NULL if it terminates before entering the message loop.

Comments

The WinMain function calls the instance-initialization function and, if no other instance of the program is running, the application-initialization function. It then performs a message retrieval-and-dispatch loop that is the top-level control structure for the remainder of the application's execution. The loop is terminated when a WM_QUIT message is received, at which time this function exits the application instance by returning the value passed by the PostQuitMessage function.

See Also

DispatchMessage, GetMessage, PostQuitMessage, TranslateMessage