The easiest way to handle the print stream end of things is with a separate application using the PrinterChangeNotification API to look for new jobs, and the spooler Job API to cancel the ones you don’t want. But that’s not ironclad. These are asynchronous, so a small job could already be completed before your decision is made or your subsequent order to cancel it reaches the spooler. The application would need to be able to administer every printer used, which is problematic.
Either a print processor or a port/language monitor could potentially do this, but it’s still not ironclad, and I believe someone determined to subvert it could still succeed [by supplying their own printer driver that just stuffed the output anywhere in the cloud without ever letting the spooler see it, for instance]. These components are replaceable. The system has multiple port monitors inbox, and some of them are quite complex and not published. But I’m assuming you want this to happen for all print activity on the machine, which may not be the case.
For the processor or monitor the cancel logic is simple enough- they just stop processing the job once the decision is made, and say they did what they were asked to. FWIW, I probably wrote one of the first of each that worked that way [I was the test developer for printing on the original release of Windows NT, and components that swallowed massive amounts of data silently had myriad uses in testing other components].
If you’re prototyping something, the port monitor is the easiest piece to understand, and the source to one of the most commonly used monitors [localmon] is in the DDK/WDK [used to be, anyway].
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@zju.edu.cn
Sent: Thursday, September 21, 2006 6:48 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] about monitor and cancel print request
i want to implement the following funtion:
when a application want to print a document , the print request is automatic identified ,and the document name and type is retrieved. According to the name and type, the decision is made to continue or stop the printing.
Maybe it is very very easy, but for me ,i have no idea about this. Port Monitor? Print Processor? or Hook print api?
anyone can give me suggestion?
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer