Windows CE Printer Driver implementation

Source: Internet
Author: User

Windows CE 2.0 and later versions include printer support. The print model used by the Windows CE operating system is a subset of the print model defined on the Windows CE-based desktop platform. Only a small number of graphic driver functions defined for the printer driver are required by the Windows CE printer driver.

Windows CE graphic display interface (GDI) and display driver complete most of the work related to printing. At the beginning of the print processing, GDI generates the device background deviec context with attributes, which are obtained from the printer driver when the drvenablepdev function is called. The display driver is used to submit (render) subsequent drawing commands sent by the application to DC: The printer driver does not submit (render) this document. Then, GDI sends the result dot matrix to the printer driver so that the printer driver can format the dot matrix and send it to the printer. To save memory, GDI submits documents in batches, that is, the page level is not equal: Then, GDI calls the printer driver multiple times to send the submitted documents to the printer.

Windows CE-based printer drivers can only implement some graphics driver functions, these functions are required to collect printer metrics, set printers, start and end print tasks, and prepare submitted print content. During the intermediate process, the printer driver also converts the dot matrix data from the GDI bitmap format to the format required by the printer. The operations include simplifying the color to the color space of the printer, compressing the data, and converting the data into the format used by the printer, which is sometimes called the printer Description Language. Finally, the printer driver calls the monitor to send the submitted print content to the printer.

The Windows CE-based printer driver is compiled as (. dll), so it must output the drvenabledriver function.

The following functions must be implemented by the printer driver:

1. drvcopybits is called by GDI to copy submitted batches to the printer driver. When the drvdisablepdev function is called, the printer driver specifies the format of the dot matrix used to call this function.

2. drvdisbalepdev is used to release the memory and resources used by the driver when the printer device is no longer needed.

3. The drvdisablesurfacd is called by GDI to notify the printer driver that the appearance (windws CE) generated for the current printing device environment is no longer supported

4. drvenabledriver receives two callback function pointers from GDI and returns the GDI function pointer for other entry points implemented by the printer driver.

5. drvenablepdev is used by GDI to collect printer metrics for the target printer. The Printer Driver returns the device specified in the gdinfo Structure

6. The drvenddoc is called by GDI to end or stop a printing task in the middle. 7. drvgetmodes returns the Printer Driver Support and saves the print mode information to GDI. The Printer Driver returns in the devmode structure but saves configuration 8. drvstartdoc is called by GDI to start printing. 9. drvstartpage is called by GDI to start a next page for printing.

Windows CE uses a registry to store the global printer settings and configurations of a single printer driver. The key value is stored in KEY_LOCAL_MACHINE/Printers/in the registry.

1. Global printer settings

The global printer settings stored in the registry list the input (I/O) ports used for printing, provides the global timeout value and stores the selected printer driver in a saved state. Saving the printer driver stored as the defaultprinter value. The printer interface is stored as the/ports sub-key value. The following registration file excerpt defines five printer ports, two timed-out and saved printer drivers.

(HKEY_LOCAL_MACHINE/Printers/ports) "port1" = "COM1: 9600" "port2" = "COM1: 57600" "port3" = "IrDA" "port4" = "LPT: "" port5 "=" net0: "(HKEY_LOCAL_MACHINE/Printers/settings)" timeout "= DWORD: 1E (HKEY_LOCAL_MACHINE/printersettings)" timeout "= DWORD: 2D (HKEY_LOCAL_MACHINE/printers) defaultprinter "=" PCL Laster"

The values are the serial ports of port 9600 and port 57,600, an infrared port, a parallel port, and a network printer interface. For two COM1 ports, the corresponding port is specified. The interface monitor analyzes the port value to be extracted and the device file name. In Windows ce2.0, The com3 port is set to infrared. However, in versions 2.10 and later, the file name "IrDA" is left as an infrared port, while com3 is used for additional serial port. When assigning an infrared port for printing, the key value of the interface must be the string "IrDA", although this value is not the standard format of the specified device file name. The names "LPT1:" and "net0:" are reserved as parallel ports and network print ports, although the device file name index in these names can be any valid value. Windows CE 2.02 and later versions both use the timeout key. This value is the hexadecimal number measured in seconds. In this example, it is a timeout of 30 seconds. After a time-out period, the printer driver can display a dialog box for the user to choose to retry or cancel. In this example, the printer driver "PCL laser" is the name of a child in KEY_LOCAL_MACHINE/priners. In KEY_LOCAL_MACHINE/priners/, you can find the printer control language (PCL) laser printer driver configuration.

For printers that do not use parallel ports, such as infrared printers or serial port printers, it is very difficult for Windows CE to determine whether the printer accepts all printed data. Therefore, the timeout parameter is used to detect and report print errors when the printer cannot send any signal that the printer is still active. Supermarket values are stored in the printsetting/timeout key. The saved value is 45 seconds. The value stored in the defaultprinter key is the printer that the application displays to the user in the general Print dialog box and is pre-selected by the user.

2. printer driver settings

The setting of a single printer driver is stored in the KEY_LOCAL_MACHINE/Printers key. The registration keys of the printer driver should be defined as driver, high quality, draft quality, and color. The driver Value List contains the DLL of the printer driver. If the printer supports this, the hight quality and draft quality values store resolution in both high quality and Drawing Quality modes. Not all printers support the drawing quality mode, so the draft quality key can be ignored. The high quality key must be provided, which corresponds to the highest quality mode of the printer. The color value defines whether the printer is color or monochrome. If color is supported, the key value must be set to the character "color".

The following is an example of how to configure the driver for the PCL and PCL inkjet printer: (heky_local_machine/peinters/PCI laser) "driver" = "pc1.dll" "high quality" = "300" "Draft quality" = "150" "color" = monochrome "" version "=" 0x200"

(HKEY_LOCAL_MACHINE/peinters/PCL inkjet) "driver" = "PCL. DLL "" high quality "=" 300 "" draft quality "=" 150 "" color "=" monochrome "and the version key can be used to support printer drivers to serve multiple printers!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.