2.2.2 Handles

Two of the WinMain function parameters (hinstPrevious and hinstCurrent) are called handles. A handle is a unique integer that Windows uses to identify an object created or used by an application. Windows uses a wide variety of handles, identifying objects such as application instances, windows, menus, controls, allocated memory, output devices, files, and graphics device interface (GDI) pens and brushes.

Most handles are indices into internal tables. Windows uses handle indices to access information stored in these tables. Typically, an application has access only to the handle and not to the information. When the application must examine or change the information, it supplies the handle, and Windows does the rest. This is one way that Windows protects information with its multitasking capabilities.