A method and system for enabling a printing program to communicate with a
printer relies on a plug and play manager to detect the presence of a
printer and send a notification message to the printing program when a
device driver registers a new device in the operating system registry. In
response to the message, the printing program calls a function in a
dynamic port monitor that retrieves the new device registration
information from the operating system registry. The dynamic port monitor
then creates a port name for the printer and associates it with the
physical printer port. The dynamic port monitor also periodically
determines whether any excess ports need to be deleted.