在 C# 上打印事件 [英] Printing event on C#

查看:49
本文介绍了在 C# 上打印事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何跟踪打印机的活动,例如:

How can I keep track of Printer's activities such as:

  • 印刷是什么时候开始的?
  • 打印了多少页?等

推荐答案

您可能希望使用 FindFirstPrinterChangeNotificationFindNextPrinterChangeNotificationFindClosePrinterChangeNotification 函数.并收听 PRINTER_CHANGE_JOB 事件.当引发打印作业事件时,您可以从 PRINTER_NOTIFY_INFO_DATA 结构.

You would want to set up a service that listens to printer change notification events using the FindFirstPrinterChangeNotification, FindNextPrinterChangeNotification, and FindClosePrinterChangeNotification functions. And listen to the PRINTER_CHANGE_JOB event. When a print job event is raised you can get access to the necessary job information from the PRINTER_NOTIFY_INFO_DATA structure.

这个方法应该持保留态度.我从经验中发现,当服务器负载不足且同时发生许多打印作业时,打印机事件是不可靠的.某些打印机事件不会触发.

This method should be taken with a grain of salt. I have found from experience that printer events are unreliable when the server is under load with many print jobs occurring at the same time. Some printer events will not fire.

显然这个解决方案需要大量的 P-Invoking &编组,所以我祝你好运.如果使用 C++ 编写应用程序是一种选择,那么在这种情况下,它可能比使用 C# 更容易.

Obviously this solution will take a whole lot of P-Invoking & Marshalling, so I wish you luck. If writing the application in C++ is an option it would probably be easier than in C# in this case.

这篇关于在 C# 上打印事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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