Browse DevX
Sign up for e-mail newsletters from DevX


Empower Your Printing with Custom Print Processors : Page 4

Using Custom Print Processors is one of the many ways to take control of the printing process. Find out how to use this user-mode DLL and C/C++ to enforce security policies, add missing printing functionality, or alter print jobs.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Installing the Print Processor
The following actions will install your Print Processor on the Print Server or your local computer (of course, all these operations can be automated when creating the installer for your application):
  • Copy the compiled DLL to the Print Processors folder:


  • Create a new Registry Key Separator under the existing [HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Print Processors] key.
  • Add the driver REG_SZ variable to the newly created Separator key with the Print Processor DLL name as its value (in this case, Driver=SeparatorPP.dll).
  • Restart the Windows Spooler Service using the Services applet or with the following commands:

    net stop spooler net start spooler

    For your convenience, the registry script file is included in this article's source code (SeparatorPP.reg).
  • From the Control Panel, go to Printers and Faxes and open the Properties window for the printer device.
  • Go to the Advanced tab (see Figure 2) and click on the Print Processor... button. From the displayed list, choose your print processor (as shown in Figure 3). Leave the default data type as RAW (this setting is relevant only when application doesn't specify a data type for a print job; this is extremely rare; most NT systems will spool print jobs in EMF format).

Figure 2. Printer Properties: Go to the Advanced tab and click on the Print Processor button.
Figure 3. Selecting Print Processor: Choose your print processor from the displayed list.

Author's Note: Remember to always be very careful when modifying the registry, because it may cause your machine to become inoperable.

Debug Your Print Processor
As already mentioned, Print Processors run in the context of the Windows Print Spooler Service. In order to debug your application, attach to the spoolsv.exe process and place breakpoint in the code. This is really easy if you’re using Microsoft Visual Studio 7 (see Figure 4).

Figure 4. Debugging: Attach to the spoolsv.exe process and place breakpoint in the code.

Don't forget to copy the PDB file to the Print Processors folder when you wish to open a debug session.

From Hard Work to Hard Copies
Now, try printing a document to ensure that your Print Processor is functioning properly. Print it to the device which was associated with the Print Processor as explained in the "Installing Print Processor" section. The Separator.bmp file should be the first page printed with every hard copy.

Seek Out and Explore New Applications
This relatively simple technique allows you to take control of the printing activities on specific printer devices. You can use the code provided with this article or the code from the DDK to empower your printers, add missing functionality, alter print jobs, etc. Just remember not to waste too much paper testing your code—use virtual printers, print to file, or at least feed the printer with recycled paper.

Yevgeny Menaker is an author, Senior Software Engineer, and consultant. Yevgeny currently works for PortAuthority Technologies (former known as Vidius), developing security products for content analysis and preventing the leakage of sensitive information through electronic mail and other channels.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date