Programmatically set printer to bypass the windows

2019-06-21 14:55发布

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.

1条回答
放荡不羁爱自由
2楼-- · 2019-06-21 15:48

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 :)

查看更多
登录 后发表回答