Programmatically set printer to bypass the windows spooler

吃可爱长大的小学妹 提交于 2019-12-10 14:55:33

问题


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:


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



来源:https://stackoverflow.com/questions/4801049/programmatically-set-printer-to-bypass-the-windows-spooler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!