## Printer Device Driver

[prev][next][parent][TOC]

### Port-Installation Steps

The user opens an existing print object's settings notebook's "Output Port" settings page to install a new port or port driver or to update an existing port driver. This settings page has two buttons-one for installing a new port, and the other for updating an existing port driver.

To update an existing port driver, the following steps are taken:

1.If the "Update Port Driver" button is selected, the print object checks for the spooler being enabled.

2.If the spooler is enabled, the user

is told that port drivers cannot be updated while the spooler is enabled
is asked if they want to disable the spooler at this time.

3.If the spooler is disabled, the user:

is asked for the path to an updated port driver
must select a port driver from the list of port drivers that exist on that path.

To install a new printer port, the following steps are taken:

1.If the user selects the "Install New Port" pushbutton or selects the " Install" menu item from an existing port object, a dialog box appears listing all ports available to be installed by the existing port drivers. Each port driver can export the extended attribute DEFAULT_PORT-whose contents are the port name followed by a semi-colon and the port description. This is the name and description of a default new port to install for this port driver.

If the port driver does not have this extended attribute, the print object calls SplPdEnumPort to list ports available to be installed for this port driver.

The port driver can also export the extended attribute ".ICON"-which contains the port driver's icon for the new port to install. This avoids loading and calling a port driver just to display the ports available to be installed by the port driver.

There are two radio buttons in this install dialog box. The default is selected to install a new port from an existing port driver, the other button is selected to install a new port driver. If the "Install New Portdriver" is selected, the user is prompted for the path to the new port driver. The print object uses the above method to determine the installable ports.

2.When the user selects a port object to install, the print object installs the port driver-if it is a new port driver, by copying the port driver and its files and then adding the port driver entry to the system initialization file.

3.The print object calls the port driver's SplPdInstallPort API with the default port name selected by the user.

The port driver can display a configuration dialog to the user at this time . This configuration dialog can be similar to the one displayed by SplPdSetPort. The print object does not call SplPdSetPort during port installation; it is up to each port driver to decide whether or not a configuration dialog is needed when installing a new port.

If the port driver decides to display a configuration dialog during SplPdInstallPort, the port driver may need to add a "virtual" port name to the system. This is needed to allow PrtQuery and PrtSet commands to be sent to the port-driver code running under the spooler process. It is suggested that the port driver start a background thread to issue the PrtQuery and PrtSet commands, since the port driver might not even be initialized under the spooler process yet.

Once the configuration dialog is complete, the port name configured by the user can be installed and the virtual port can be removed by the port driver.

At this point, the port selected by the user is installed and ready to connect to a print object.