About Language Monitors

There are two types of print monitors: language monitors and port monitors. Port monitors are described in About Port Monitors. For overview information about the relationship between a language monitor and a port monitor during the printing process, see Typical Printing Process Scenario Using a Raw Spool File.

Note

The illustrations in Typical Printing Process Scenario Using a Raw Spool File show the language monitor and port monitor as separate components (each packaged in a separate DLL). However, if your language monitor calls only one particular port monitor, it may be to your advantage to build one component (one DLL) that integrates the language monitor and port monitor functionality. If your language monitor might call more than one port monitor, package the language monitor in a DLL separate from any of the port monitors.

Language monitors are typically necessary only for bi-directional printer devices. A bi-directional printer supports two-way communication between the printer and code running on the computer to which the printer is connected.

The two-way communication between computer and printer is used to configure the printer and to monitor printer status. The code running on the computer can request configuration and status information from the printer and/or the printer can send unsolicited status information to the computer whenever certain events occur on the printer. For the printer to understand the requests from the computer and for the computer to understand either solicited or unsolicited responses from the printer, a language has to be defined. For example, an HP LaserJet 4Si is an example of a bi-directional printer device and the printer job language (PJL) is a language that implements all the bi-directional communication functionality mentioned in this paragraph.

A language monitor can also be used to add data, such as printer control information, to the print stream going to the printer. When a language monitor is associated with a printer driver at printer installation time, all print data that flows from the printer driver to the printer goes through the language monitor before it goes through the port monitor and out to the printer. For information on how to use INF files to associate your custom language monitor with a printer driver at printer installation time, see Printer INF File Extensions.

An important implementation detail is that when the language monitor returns to the printer driver after adding bytes (such as printer control information) to the print stream, the language monitor must not increment the byte count of data sent to printer. For example, if the printer driver sends 1K bytes to the printer and the language monitor adds .25K bytes of information to the data stream before it goes to the port monitor and out to the printer, then when the language monitor returns to the printer driver, it must report that 1K bytes were sent to the printer, not 1.25K bytes.

Sample source code for a language monitor is provided in the Windows 95 DDK. After the Windows 95 DDK is installed, the sample language monitor source code is in the \%DDKROOT%\PRINTER\SAMPLES\SPOOLER\PJLMON directory.