Required Functions

The following table describes the entry points that are exported by the port monitor.

Entry Point/Description

Comment

AddPort: A port management function that adds a port to the list of currently supported ports in the spooler environment.

Called by the spooler in order to add a port to the set of ports maintained by your monitor. The spooler calls this entry point when the user chooses the AddPort button from the Windows 95 Printer Properties dialog. You may have to implement user interface code to get all the information your AddPort function needs to create a port.

ClosePort: Closes a previously-opened port when no printers are connected to the port.

Called by the spooler to enable your monitor to clean up any resources, such as data structures, that are associated with one of the ports your port monitor is maintaining.

ConfigurePort: A port management function that configures the specified port. If the port is a COM port, configures the baud rate. If the port is a parallel port, configures retry parameters. If the port is a network port, may change the port address.

Called by the spooler when the user chooses the Port Settings button from the Windows 95 Printer Properties dialog. This enables your port monitor to present a user interface that allows a user to configure one of the ports maintained by your port monitor.

DeletePort: A port management function that frees the port monitor of any responsibility for managing the port or monitoring print jobs on the port.

Called by the spooler when the user chooses the Delete Port button from the Windows 95 Printer Properties dialog. When the DeletePort function is called in your port monitor, it should delete all knowledge of the specified port from your port monitor. This function will never be called when the specified port is in use (opened).

EndDocPort: Performs end-of-print-job tasks on the specified port.

EndDocPort is called after all the data in a print job has been passed to your port monitor using WritePort function calls.

EnumPorts: A port management function that provides a list of all the ports available for printing on the local machine through your port monitor.

Called by the spooler to get the list of ports maintained by your port monitor. The spooler calls all installed monitors in turn to build up a list of all the available ports.

GetPrinterDataFromPort: Gets data from a bi-directional printer by providing IEEE 1284 support.

InitializeMonitorEx: Sets up the function pointer table that registers with the spooler all the other entry points provided by your port monitor.

Your port monitor should establish function pointers for a set of port management functions (AddPort, ConfigurePort, DeletePort, and EnumPorts) and a set of printer and print job monitoring functions (OpenPort, ClosePort, StartDocPort, EndDocPort, WritePort, and ReadPort).

OpenPort: Opens the specified port.

When the OpenPort function is called, it should set up all resources, such as initialized data structures, needed to print to the specified port.

ReadPort: Reads data from the printer.

The ReadPort function is called to get information from a bi-directional printer. If your ReadPort function can read data from the printer, it should return that raw data to the caller (which is probably a language monitor). If your ReadPort function cannot read any data from the printer within some appropriate time interval, it should return a failure code.

SetPortTimeOuts: Sets a time out value on an open port.

StartDocPort: Performs the tasks it takes to start a print job on the specified port.

The StartDocPort function is called at the start of a print job. The StartDocPort function in your port monitor should setup whatever is needed for your port monitor to print the data that will be provided in subsequent WritePort and any subsequent ReadPort function calls.

WritePort: Writes data to the printer.

The WritePort function is called repeatedly to send blocks of data to the printer. The WritePort function in your port monitor can call the SetJob function to modify print job state information.