How are printer notifications in Windows supposed to work with network printers?
Asked Answered
S

0

1

I have an application which needs to print files of different types using their associated applications for printing using ShellExecute and the "print" verb. My application needs to (hopefully) reliably know when one print job is completely processed and it can issue the next one. I accomplish this using FindNextPrinterChangeNotification and everything seems to work fine using local printers, e.g. installed via USB, but I get a completely different behavior if network printers are involved.

One of my clients used my application with a network printer, meaning a professional printer with it's own print server embedded, installed on a Windows Server 2008 R2 and shared this installed printer using Windows to it's clients. In this scenario FindNextPrinterChangeNotification always returned success, but it's returned structures got the flag PRINTER_NOTIFY_INFO_DISCARDED set always as well. I could reproduce this behavior with a Windows Server 2008 R2 on my own which didn't export a printer with it's own embedded printer server, but simply a locally installed FreePDF XP. Additionally, I get the same behavior if I use samba, cups and cups-pdf on one of our Ubuntu development servers: Samba successfully exports the cups-pdf printer and if I install it in my Windows 7 development machine and use it with my print application, FindNextPrinterChangeNotification returns successfully always, but again always with the flag PRINTER_NOTIFY_INFO_DISCARDED set.

My customer afterwards installed his printer directly via the printer's embedded print server to it's clients and told me that my print application is now working as with a local printer. Meaning no more events with PRINTER_NOTIFY_INFO_DISCARDED flag set as in his version of my application this is an error state which would exit the application.

I tried to reproduce that using cups-pdf again, this time I didn't install the printer exported by Samba, but directly by specifying the printer name of cups using the URL http://domain.example.org:631/printers/PDF. I can successfully use this printer in Windows, but my application again gets strange events. This time I don't get results with the flag PRINTER_NOTIFY_INFO_DISCARDED set, but ppPrinterNotifyInfo is always NULL, I don't get any results at all, but FindNextPrinterChangeNotification returns successfully.

Microsoft provides a note about Firewalls and printer notifications may get blocked by clients, but I don't think that this is the problem in my case because I already tested the same scenarios with a disabled firewall, with enabled firewall the results differ depending on how my development machine is speaking to the printers and my Windows 7 firewall settings seem to allow printer communication by default.

To make a long story short: I didn't find anything on how reliable printer notifications are for different network printers. Is everything depending on the printer drivers? Doesn't seem so because it makes a different if Samba exports a printer or one uses http directly. From what I've read Windows 7 uses client rendering of print jobs and afterwards sends the jobs to the network spooler, I can see those jobs in my local spooler for a long time. Why don't I get notifications as well? Are Samba and printers shared using a Windows Server by design not supposed to publish printer notifications? I couldn't find any info saying that.

I would really appreciate any help or hints for docs which could provide some light on this. Thanks!

Sumter answered 3/9, 2013 at 14:43 Comment(2)
Print server and client should be in same AD domain or have explicit access with 'net use' command. Please, read more info about anonymous access to the named pipes on Windows and remote printer access authentication.Turkic
I didn't use AD on my tests and I'm pretty sure that my user with which I tested had full acces to the printer share, at least it was created on the server. My local print spooler showed me the state of my print job, only using the API I didn't get the same information like with local or network printers, which were not shared using Samba or Windows Server.Pippa

© 2022 - 2024 — McMap. All rights reserved.