To monitor printer jobs, you can use the FindFirstPrinterChangeNotification
API call with PRINTER_CHANGE_WRITE_JOB
passed in the fdwFilter
parameter. This will let you know every time job data was written to the printer via FindNextPrinterChangeNotification
.
When you're done, don't forget to call FindClosePrinterChangeNotification
to close all the handles and clean up.
The use can get rather complicated. Dr. Peter Below of TeamB posted a unit that has wrappers around this a while back to the old Borland Code Central pages (which are now available at the Embarcadero site) in a unit called PBPrintersMonitorU.pas
. You can find it here, if you have an EDN (Embarcadero Developers Network) account.