The Windows API Library Files

The Dynamic Link Library (DLL) files that make up the Windows API are commonly located in the Windows SYSTEM subdirectory. These files are found on every PC that is running Windows, so you don't have to worry about including them if you create a set of setup disks for distribution.

The three major Windows DLLs are USER32.DLL, KERNEL32.DLL, and GDI32.DLL. Several smaller DLLs are known as extension DLLs and provide functions in addition to those found in the three major DLLs. Some useful extension DLLs include the following:

COMDLG.DLL
DLLLZ32.DLL
VERSION.DLL
APIGID.DLL
COMCTL32.DLL
MAPI32.DLL
NETAPI32.DLL
ODBC32.DLL
WINMM.DLL

The following sections discuss in some detail the primary purposes of each DLL as well as some examples of the functions they provide.

USER32.DLL

The USER32.DLL library file contains functions that relate to managing the Windows environment, such as

  • Handling messages between windows
  • Managing cursors
  • Managing menus
  • Handling other non-display functions

The following list outlines some of the functions of the USER32 library:

  • GetCursorPos& returns the cursor's screen position in X and Y coordinates.
  • SetWindowPos& sets a window's position, size, state, and Z-order.
  • GetParent& returns the handle of a parent window.
  • GetActiveWindow& returns the handle of the active window.
  • SendMessage& sends a message to a window, triggering an event for that window or telling it to perform some action.

GDI32.DLL

The GDI32.DLL library file (the Graphics Device Interface library) contains functions that help manage output to different devices, especially the screen. Following are some of the functions in GDI32:

  • BitBlt& copies a bitmap image between two device contexts.
  • DeleteObject& deletes a GDI object (that is, fonts or bitmaps) from memory.
  • RoundRect& draws a rectangle with rounded corners.
  • SelectObject& selects a graphics object into a device context.
  • StretchBlt& stretches and manipulates a bitmap image as it copies it from one device context to another.

KERNEL32.DLL

The KERNEL32.DLL library contains functions that manage the low-level operating system functions. These functions include

  • Memory management
  • Task management
  • Resource handling
  • File and directory management
  • Module management

Here are some of the functions in the KERNEL32 library:

  • GetSystemDirectory& returns the full path of the Windows system directory.
  • GetTempFileName& returns the path and name of a temporary file that can be used by an application.
  • GetModuleFileName& returns the full path name for a module (that is, DLL or application) that is loaded into memory.
  • GetVersionEx& returns the versions of DOS and Windows currently running on the system.

The Extension DLL Libraries

The extension DLLs are libraries added to Windows when the functionality of Windows has changed in some way, usually with the addition of new features to the operating system. Instead of completely rewriting the operating system whenever a new feature is added, a new DLL is added to the system that includes the functions that add the new feature to the operating system. For example, when Microsoft added multimedia capabilities to Windows, it created a new DLL that includes the multimedia functions, WINMM.DLL.

The major extension libraries that are a part of Windows are

  • COMCTL32.DLL adds the new Windows common controls that are part of Windows 95 and Windows NT 4.0. Examples of these include the ToolBar and TreeView controls.
  • MAPI32.DLL implements the functions that let any application work with electronic mail.
  • NETAPI32.DLL adds a set of functions that enable applications to access and control networks.
  • ODBC32.DLL implements a set of functions that let applications work with databases that are ODBC-compliant. ODBC stands for Open Database Connectivity.
  • WINMM.DLL implements a set of functions that access the operating system's multimedia capabilities, such as playback of sound and video.

These are the library files and extensions to the Windows operating system you will call when you write programs that access the Windows API. After you learn how to call these libraries from your Visual Basic applications (the subject of the next section), you can tap the full power of the Windows environment.

Top Home