2.2.1 Data Types and Structures

The WinMain function uses several special data types to define its parameters. For example, it uses the HANDLE data type to define the hinstCurrent and hinstPrevious parameters, and the LPSTR data type to define the lpszCmdLine parameter. In general, Windows applications use many more data types than are found in a typical C-language application. Although the Windows data types are often equivalent to familiar C-language data types, they are intended to be more descriptive and should help you better understand the purpose of a variable or parameter used in an application.

The Windows data types are defined in the WINDOWS.H header file. This file is an ordinary C-language source file that contains definitions for all the Windows special constants, variables, structures, and functions. To use these definitions, you must include the WINDOWS.H file in each source file. Place the following line at the beginning of your source file:

#include <windows.h> /* required for all Windows applications */

Following are some commonly used Windows data types:

Type Meaning

WORD Specifies a 16-bit, unsigned integer.
LONG Specifies a 32-bit, signed integer.
HANDLE Identifies a 16-bit, unsigned integer to be used as a handle.
HWND Identifies a 16-bit, unsigned integer to be used as a handle of a window.
LPSTR Specifies a 32-bit address of a character string (of type char)
FARPROC Specifies a 32-bit address of a function.

Following are some commonly used structures:

Structure Description

MSG Contains information about an input message from the Windows application queue.
WNDCLASS Defines a window class.
PAINTSTRUCT Defines a structure used to paint the client area of a window.
RECT Defines a rectangle.

For a complete listing and description of Windows data types and structures, see the Microsoft Windows Programmer's Reference, Volume 3.