Printing from a Service | CodeGuru

Printing from a Service

Environment: Windows NT 4 The Problem Have you ever attempted to print from a Windows NT Service? Some time ago my colleagues and I wrote a TCP/IP server to collect data, analyze it and then print exceptions. Obviously, printing is usually a very simple and typical task for any software engineer. When I finished developing […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 30, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: Windows NT 4

The Problem

Have you ever attempted to print from a Windows NT Service?

Some time ago my colleagues and I wrote a TCP/IP server to collect
data, analyze it and then print exceptions. Obviously, printing is usually a very
simple and typical task for any software engineer.

When I finished developing this application, I then converted it to a Windows NT service.
Everything seemed to work well with one exception. The application wouldn’t print
anything!

With my heart in my hands, I then began the arduous task of walking the registry
and searching for a solution. Finally, I found it after a few days.

The solution

  • Locate the following registry key
  • HKEY_CURRENT_USERSoftwareMicrosoftWindowsNTCurrentVersionWindows
    
  • Write down the value of "Device" as you’ll be using it soon
  • Locate the following registry key
  • HKEY_USERS.DEFAULTSoftwareMicrosoftWindowsNTCurrentVersionWindows 
    
  • Copy the previous information into the field "Device"
  • Reboot your PC

That’s it! Now you can print from a Windows NT service.

Warning!

Modifing your registry incorrectly can result in serious, system-wide problems.
Therefore, use this advice at your own risk.

Acknowledgements

Thanks to my friend Maurizio Picco for his usefull help.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.