清除本地打印机队列中的作业 [英] Clear jobs in local printer queue

查看:222
本文介绍了清除本地打印机队列中的作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,

我目前正在开发一种售票亭系统,该售票亭系统使用USB端口上的BOCA打印机进行票证打印.

我使用winspool.drv功能与打印机通信.

有时,当应用程序启动时没有在打印机中装入票证时,测试打印文件将位于打印机队列中,但是通常在代码从打印机缓冲区中退出票证状态后将其删除.如果您在完成此操作之前重新启动该应用程序或结束其任务,则打印作业将保留在队列中并且不会被删除.当您重新启动应用程序时,将遵循相同的步骤,它将向队列中添加一个新作业,这又将在尝试执行StartDocPrinter时返回错误(此函数超时),然后该应用程序将无法启动.

我想做的是启动应用程序时,清除在本地连接的打印机的打印队列中找到的所有作业.

我一直在寻找代码,并尝试使用SetJob(winspool.drv),但我没有与队列中的作业关联的JobID,因此我无法将其设置为取消.

我要么不了解取消过程,要么就无法取消工作.

有人可能对我的问题有任何建议吗?

谢谢.

Good afternoon,

I''m currently developing a kiosk system making use of a BOCA printer on USB port for ticket printing purposes.

I communicate with the printer using winspool.drv functionality.

Sometimes when the application starts up with no tickets loaded in the printer a test print file will be in the printer queue but will usually be removed after the code has returned out of ticket status from the printer buffer. If you restart the application before this is done, or end task it, the print job will stay in the queue and not be removed. When you then restart the application the same steps will be followed and it will add a new job to the queue which in turn will then return an error when trying to execute StartDocPrinter (this function times out) and the application will then not start-up.

What I would like to do is when the application starts up, clear all jobs found in the print queue for the local attached printer.

I have been looking for code and tried using SetJob (winspool.drv) but I don''t have the JobID''s associated with the jobs in the queue so I can''t set them to cancel.

I''m either not understanding the cancel process or it''s just not possible to cancel the jobs.

Does anybody maybe have any suggestions to my problem?

Thanks.

推荐答案

PrintQueue.Purge方法

http://msdn.microsoft.com/en-us/library/system. printing.printqueue.purge.aspx [ ^ ]

请注意,这将清除队列中的所有内容.
PrintQueue.Purge Method

http://msdn.microsoft.com/en-us/library/system.printing.printqueue.purge.aspx[^]

Be aware, this will clear everything in the queue.


这篇关于清除本地打印机队列中的作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆