Printing from a Service
Posted
by Fabio Angelini
on July 30th, 1999
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
- Write down the value of "Device" as you'll be using it soon
- Locate the following registry key
- Copy the previous information into the field "Device"
- Reboot your PC
HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows
HKEY_USERS\.DEFAULT\Software\Microsoft\WindowsNT\CurrentVersion\Windows\

Comments
How can i do to print document from SYSTEM account ???
Posted by Legacy on 01/16/2002 12:00amOriginally posted by: Barbier J�r�me
ReplyLog from NT service without using Event Log
Posted by Legacy on 02/19/2000 12:00amOriginally posted by: Tibor Hellvig
I have converted a program to NT service and now my logging to a regular text file no longer works. Can anyone help?
ReplyThis works for any program called by a service
Posted by Legacy on 11/21/1999 12:00amOriginally posted by: Bernard Cheung
Thanks to this solution, I am able to use Windows NT's AT command or some Scheduler program to schedule print jobs of third party programs.
cheers
Bernard
ReplyWhere's the problem ?
Posted by Legacy on 11/16/1999 12:00amOriginally posted by: Bernard Alleysson
I did not find any problem to print from a service I've written. I'm just using:
m_hDC = CreateDC(
_T("WINSPOOL"),
pszDevice, NULL, pDevMode
);
where pszDevice is the UNC name of the printer ie
\\server\printername
IMHO, no registry copy needed
Reply