System.Printing.PrintQueue QueueStatus 未更新
有没有办法更新 PrintQueue 对象?
我尝试致电 刷新 PrintQueue 对象,但这并没有真正做任何事情。例如,我关闭了打印机,并且控制面板正确地将打印机显示为“脱机”,但是 QueueStatus 属性以及 IsOffline 属性都没有反映这一点 - 无论我在两个队列上调用 Refresh 多少次打印服务器 和有问题的 PrintQueue 。
我已经看到了如何使用 WMI 查询获取状态信息的示例,但我想知道 - 因为这些属性可在 PrintQueue 对象 - 是否有任何方法可以使用它们。
Is there a way to update the print queue status information contained in the PrintQueue object?
I've tried calling Refresh on the PrintQueue object but that doesn't really do anything. For instance, I've turned off the printer and the Control Panel correctly shows the printer as "Offline", however the QueueStatus property, as well as the IsOffline property don't reflect that - no matter how many times I call Refresh on both the PrintServer and the PrintQueue in question.
I've seen examples of how to get status information using WMI queries but I wonder - since these properties are available on the PrintQueue object - whether there is any way to use those.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试打印 PrintDocument (System.Drawing.Printing) 后,尝试检查打印作业的状态。
第一步:
初始化您的打印文档。
第二步:(); 获取打印机名称
从 System.Drawing.Printing.PrinterSettings.InstalledPrinters.Cast
并将其复制到
printerDocument.PrinterSettings.PrinterName
第三步:
尝试打印并丢弃。
最后一步:在任务中运行检查(不要阻塞 UI 线程)。
这是实现:
祝你好运。
After try to print your PrintDocument (System.Drawing.Printing), try to check status of printjobs.
First step:
Initialize your printDocument.
Second step:
Get your printer Name From
System.Drawing.Printing.PrinterSettings.InstalledPrinters.Cast<string>();
And copy it into your
printerDocument.PrinterSettings.PrinterName
Third step:
Try to print and dispose.
Last step: Run the check in a Task (do NOT block UI thread).
Here is the implementation:
Good luck.
很晚的答案,
到目前为止我发现的唯一方法是重新启动打印后台处理程序服务,但这会导致 WMI 出现一系列其他问题,而且这不是一个干净的解决方案。
Very late answer,
The only way I found so far is restarting the print Spooler service but this causes a bunch of other problems with WMI and it's not a clean solution.