1.1 What Is a Device Driver?

A Windows device driver is a dynamic-link library (DLL) that Windows uses to interact with a hardware device such as a display or a keyboard. Rather than access devices directly, Windows loads device drivers and calls functions in the drivers to carry out actions on the device. Each device driver exports a set of functions; Windows calls these functions to complete an action, such as drawing a circle or translating a keyboard scan code. The driver functions also contain the device-specific code needed to carry out actions on the device.

Windows requires device drivers for the display, keyboard, and communication ports. Mouse, network, and printer drivers are required if the user adds these optional devices to the system. The following is a brief description of each type of driver.

Driver Description

Communications Supports serial and parallel device communications. Windows loads and enables this driver, checking the COMM.DRV setting in the SYSTEM.INI file to determine the filename of the driver to load. The communications driver must provide functions to enable and disable the communication device, to get and set the device status, and read and write data through the device. The USER module provides a general interface for Windows applications to call, and translates these calls into appropriate calls to the driver. The module name for the communications driver is COMM.
Display Supports the system display and cursor for pointing devices. Windows loads and enables the display driver, checking the DISPLAY.DRV setting in the SYSTEM.INI file to determine the filename of the driver to load. The display driver must provide functions to enable and disable the device, get information about the capabilities of the device, carry out graphics operations such as drawing lines and transferring bitmaps, and to show and hide a cursor. Windows and Windows-based applications call functions in the GDI module to carry out graphics operations on the display, and GDI translates these calls into corresponding calls to the driver. Depending on the capabilities of the display device, GDI may generate many calls to the driver from a single call from an application. The module name for the display driver is DISPLAY.
Grabber Supports the management of non-Windows applications. Although not technically a driver, a display grabber plays a similar role as a device driver in helping the WINOLDAP module manage non-Windows applications. A display grabber provides the support Windows needs to share the display device with non-Windows applications. WINOLDAP loads the display grabbers and calls grabber functions to carry out tasks such as capturing the contents of the screen, or managing output from a non-Windows application. Windows requires unique display grabbers for standard and 386 enhanced modes.
Keyboard Supports keyboard input. Windows loads and enables the keyboard driver, checking the KEYBOARD.DRV setting in the SYSTEM.INI file to determine the filename of the driver to load. The keyboard driver must provide functions to enable and disable the keyboard, and to translate keyboard scan codes into character values and virtual-key codes. A keyboard driver also replaces the MS-DOS keyboard-interrupt handler with its own. When the driver is enabled, the USER module provides the address of a callback function that the driver calls whenever an event occurs, such a keystroke. The module name for the keyboard driver is KEYBOARD.
Mouse Supports mouse or other pointing device input. Because a mouse is optional, Windows checks the MOUSE.DRV setting in the SYSTEM.INI file to determine whether to load a driver. A mouse driver must provide functions to enable and disable the mouse, retrieve information about the mouse, and allow users to modify the operation of the mouse through Control Panel. When the driver is enabled, the USER module provides the address of a callback function that the driver calls whenever an event occurs, such as a mouse movement. The module name for the mouse driver is MOUSE.
Network Supports networks. Because a network is optional, Windows checks the NETWORK.DRV setting in the SYSTEM.INI file to determine whether to load a driver. A network driver must provide functions to retrieve information about the network, redirect local drives, and add jobs to a network print queue. The network driver may use MS-DOS functions, NetBIOS routines, and network software to complete these network requests. Windows does not require a specific module name for the network driver.
Printer Supports printer output. Windows applications indirectly load printer drivers by calling the CreateDC function in the GDI module. A printer driver must provide functions to enable and disable the printer, to get information about the capabilities of the printer, to carry out graphics operations such as drawing lines and transferring bitmaps, and to display dialog boxes to let the user change printer settings. Windows and Windows-based applications call functions in the GDI module to carry out graphics operations on the printer, and GDI translates these calls into corresponding calls to the driver. Windows does not require a specific module name for a printer driver.

Since the network and printer drivers are optional, their module names are not reserved. However, you should name your driver to represent your device appropriately. For example, you could use PSCRIPT for a PostScriptÒ printer driver or MSNET for an MSÒ-Network driver.