PrintDialog 过滤打印机列表
我需要,最好是用 C# - 但 C++ 也可以,找到一种方法来过滤 Windows 打印对话框中的打印机列表以进行任何 Windows 打印。
我遇到了 WinAPIOverride,并认为我必须编写自己的 dll,它重写获取打印机列表的方法,然后过滤它并返回它。 然后我必须将 dll 注入到所有正在运行的进程中。
任何人都可以帮助我完成已经开发的东西或者可能是完成此任务的更简单的方法吗? 输出打印机列表的唯一方法是通过 API 方法调用,我什至考虑过修改注册表,但这会减慢打印对话框的响应速度,以至于让用户感到厌烦。
I need to, preferably in C# - but c++ will do, find a way to filter the list of printers in the windows print dialog for any windows printing.
I have come across WinAPIOverride and have figured I am going to have to write my own dll which overrides the method to get the printers list, then filter it and return it. I would then have to inject the dll into all running processes.
Can anybody assist me with something that is already developed or perhaps an easier way of accomplishing this? The only way the list of printers comes out is from the API method call and I have even considered modifying the registry, but this will slow down the response of the print dialog box to the point that it would be annoying to the user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为(重新)编写 DLL 是最简单的方法。 为什么不使用 WMI 来检索想要的 < a href="http://msdn.microsoft.com/en-us/library/aa394363.aspx" rel="nofollow noreferrer">信息(本例中为打印机)?
以下代码用于检索所有本地安装的打印机:
(代码示例借自 此处)
要获得跨域已知的打印机,请使用以下命令:
当然,该列表不会像您希望的那样“过滤”,因为您没有指定任何条件。 但我相信从现在开始你可以自己处理。
I don't think that (re)writing a DLL is the easiest method. Why not use WMI to retrieve the wanted information (printers in this case)?
The following code is for retrieving all the locally installed printers:
(code samples borrowed from here)
To get the printers known accross a domain use this:
Of course, the list is not "filtered" as you would like as you didn't specify any criteria. But I'm sure you can manage from here on by yourself.
感谢您提供有趣的代码。
这个想法是在不干扰用户的情况下尽可能全局地将过滤后的打印机列表应用到系统。 不幸的是,这意味着过滤列表必须应用于标准 Windows 打印对话框...
因此您的 WMI 代码虽然很酷,但并不合适。 如果我正在构建自己的打印对话框,它可能会非常方便;)
Thanks for the interesting code.
The idea is to apply a filtered printer list to the system as globally as possible without interfering with the user. This means the filtered list has to apply to the standard windows print dialogs unfortunately...
So your WMI code, albeit kind of cool, would not be appropriate. If I were building my own print dialogs, it could come in pretty handy ;)