Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing - Is this possible??

Status
Not open for further replies.

jshurst

Programmer
Oct 27, 2004
1,158
US
I would like to write a service to montior al printing that goes on (for a laptop computer). Ideally this would try to print to the default printer first. If this printer is not the one the computer is connected to then it would go to the next printer and try that one (and so on). Does anyone have any suggestions for this, or know if this would be the right way to go (a windows service).

Thanks,

Jeremy
 
Your program is only talking to the printer driver, not the printer itself. You will all the time find the driver, if it's installed. The driver will accept your print job without checking for the readiness of any printer. The driver (spooler), generally, does not care where a printer is currently connected to any of your ports, nor even whether any connected printers are turned on.

Unless your printer driver comes with some API for smart dialog, I don't see how you can pull that one off.
 
A couple of clarifications.

1. Printing a job involves at least two processes that are disconnected: spooler, printer driver. The spooler accepts your job without checking with the driver. The spooler will send the job to the driver only when it is good and ready. For all intents and purposes, your program would probably have ended long ago when that happens. When the driver finally gets to it, there is nothing you can do. The spooler will hold your unprinted stuff, though, until someone manually connects that printer.

2. You can write (or find) a program that will write directly to your printer. This is the only way you can control that type of application.
 
thanks for the response. I have written some of the service, but haven't actually tried to control the printing. So far I check to see all of the installed printers, then every second I monitor the print jobs on those printers. I am going to try to actually control the print jobs today (hopefully). I am pretty sure that I can delete a print job, my only problem here is when to actually delete it. I think that I will set up some kind of variable in memory with a datetime stamp. Then check to see how old it is (I'm kinda making this up as I type) and if it is too old then I will delete the job and send the job to another printer.

I tried to use the API but found it rather difficult, so I am using the WMI instead. I will let you know if I accomplish this and possible write a FAQ on it (if this will in fact work). I'm also kinda worried about the performance of this service, if it slows my computer to a crawl then it won't be worth it.
 
Thanks for the article. I think I can make this work, however I don't think that it is worth it. Having the spoolsv.exe (which is what the service calls to monitor printing) running all of the time is eating up about 50% of my CPU. Having this run all the time is really not feasible. Clents are so frustrating some times. I mean how hard is it to select the right printer!? I think they need to learn how to go like a big boy rather than using a diaper ;- )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top