安装打印机后从系统发送到应用程序的通知 [英] Notification sent from the system to an application when a printer is installed

查看:112
本文介绍了安装打印机后从系统发送到应用程序的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我有一个在打印期间监视假脱机程序并报告在打印过程中可能发生的任何错误的应用程序.但是我的应用程序无法监视在我的应用程序已经运行之后安装的该打印对象.
简而言之,如果我先安装打印机,然后运行我的应用程序,则该应用程序可以监视该打印对象.但是在此之后,如果我安装另一台打印机,那么除非重新启动该应用程序,否则我的应用程序将无法监视第二台打印机.
我想知道是否有一种方法可以从系统获取通知,该通知告诉应用程序创建了新的打印机对象,以便应用程序也可以对其进行监视.

Currently I am having an application which monitor the spooler during print time and reports any error which may occur during printing. But my application can not monitor for that print object which is installed after my application has already been ran.
In simple words, if I install a printer and then run my application, then the app can monitor that print object. But after this, if I install another printer, then this second printer can not be monitored by my app unless I relaunch the app.
I want to know if there is a way to get a notification from the system which tells the app that a new printer object is created so that the app can monitor it as well.

推荐答案

应用程序应在通用的打印"对话框中自动枚举打印机,并将自动选择默认打印机.您要监视什么?

无论如何,当将新硬件添加到系统中时,都会发送系统范围的事件,您可以在应用程序中拦截该事件.
The app should automatically enumerate the printers in the common Print dialog, and will automatically select the default printer. What do you want to monitor?

In any event, when new hardware is added to your system, a system-wide event is sent, and you can intercept this event in your application.


您可能正在寻找 Windows设备更改消息. [
You may be looking for the windows device change message.[^] This isn''t restricted to a new printer added, so when you receive this message you would have to check if indeed a new printer was added rather than something you don''t care about.

The question of what your purpose is remains. If all you wanted to do was monitor your own print jobs, this is not useful and would seem to be a bad design. In that more common situation, you should outlaw this practice, listen to John Simmons, and let the common Print dialog tell you what printer you are using for the print job.


这篇关于安装打印机后从系统发送到应用程序的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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