The WinMain function uses several special data types to define its parameters. For example, it uses the HANDLE data type to define the hInstance and hPrevInstance parameters, and the LPSTR data type to define the lpCmdLine parameter. In general, Windows uses many more data types than you would find in a typical C program. Although the Windows data types are often equivalent to familiar C data types, they are intended to be more descriptive and should help you better understand the purpose of a given variable or parameter in an application.
The Windows data types are defined in the WINDOWS.H include file. The Windows include file is an ordinary C-language source file that contains definitions for all the Windows special constants, variables, data 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 */
The following is a list of some of the more common 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 to a window. |
LPSTR | Specifies a 32-bit pointer to a CHAR type. |
FARPROC | Specifies a 32-bit pointer to a function. |
The following is a list of some commonly used structures:
Structure | Description |
MSG | Defines the fields of an input message. |
WNDCLASS | Defines a window class. |
PAINTSTRUCT | Defines a paint structure used to draw within a window. |
RECT | Defines a rectangle. |
See the online reference for a complete listing and description of Windows data types and structures.