Table of contents
TOC
Collapse the table of content
Expand the table of content

Terminal Server Printing

Last Updated: 9/16/2016

Microsoft Windows 2000 and later supports Terminal Services, a technology that allows multiple users to connect to a single server system. This server system is called a terminal server. For a detailed discussion of Terminal Services, see the Windows SDK documentation.

If you are developing a printer minidriver or driver for Windows 2000 or later, you do not have to do anything special to support printers connected to terminal servers. However, you must follow all design, implementation, and installation guidelines specified in the Windows Driver Kit (WDK). Specifically, you must use the following rules:

All custom driver code must be reentrant. User-mode code should employ critical section objects (described in the Windows SDK documentation). Kernel-mode code should use semaphores (see EngCreateSemaphore and related functions).

Printer drivers and custom spooler components must access the registry only through interfaces provided specifically for these drivers and spooler components, as described in appropriate sections of the WDK.

Installation Considerations

Usually, all you need to do for installation is provide an INF file that can be read by Microsoft's printer class installer when a user invokes the Add Printer wizard. Sometimes, custom setup code (a co-installer or class installer) is also needed. If you must create custom setup code, remember the following:

  • Either the user or the setup code must put the terminal server into installation mode. (For more information, see the Microsoft Windows SDK documentation.)

  • Do not attempt to replace system files. Windows file protection prohibits system file replacement.

  • Avoid requiring system reboots as much as possible. Use the following guidelines:

    1. Do not replace driver files that have not changed. For example, files shared by several devices should not be updated if the most current version is already installed.
    2. If a file must be replaced, the setup code should take steps to unload the old version and then load the new version (for example, by stopping the driver service, replacing the file, then restarting the service).
    3. Requiring a user to log off, then re-log on, is preferable to requiring a system reboot.

For more information about co-installers and class installers, see Writing Class Installers and Co-Installers.

Note Before writing custom setup code, it is important to read the Terminal Services programming guidelines provided in the Windows SDK documentation.

User Interface Considerations

Custom setup code that is run by a user can display a user interface.

Almost all printer driver code runs in the spooler's execution context and therefore cannot display a user interface. User interfaces can be displayed only by printer interface DLLs, and only from within the following functions:

  • The DrvDevicePropertySheets and DrvDocumentPropertySheets functions, which create property pages.

  • The DrvPrinterEvent function, which receives event codes identifying printer events. Note that the function can display a user interface only for the PRINTER_EVENT_ADD_CONNECTION and PRINTER_EVENT_DELETE_CONNECTION event codes.

All other printer driver code executes in the spooler's context. From this context, calling MessageBox or MessageBoxEx is allowed, but you must set MB_SERVICE_NOTIFICATION. These functions are described in the Windows SDK documentation.


Send comments about this topic to Microsoft

© 2016 Microsoft