Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically set printer to bypass the windows spooler

Is there a way to programmatically configure a printer that prints to a file (local file port) to bypass the spooler service and send the data directly to the file ?

I have looked @ prnadmin.dll (nothing relevant there) and WMI (nothing relevant). Any ideas ? And no, I don't want to stop the print spooler service in Windows (XP SP3), just make the printer bypass it.

like image 497
Demo Avatar asked Oct 14 '22 17:10

Demo


1 Answers

The PRINTER_INFO_2 structure has a parameter called PRINTER_ATTRIBUTE_DIRECT. You can get the handle to the printer using OpenPrinter, get this structure, change the attribute (make sure you bitwise AND it so that you dont change any of the other existing attributes) and then do a SetPrinter with this modified structure.

Refer to this link to see how you can use SetPrinter. http://support.microsoft.com/kb/140285

Hope this helps. If so, please vote a +1 for the answer :)

like image 61
Nitin Unni Avatar answered Nov 15 '22 08:11

Nitin Unni