使用WMI查询“Win32

编程入门 行业动态 更新时间:2024-10-21 06:26:05
本文介绍了使用WMI查询“Win32_Printjob”收集所有printjobs。花了很多时间。还有其他选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用ManagementObjectSearcher类并使用查询," SELECT * FROM Win32_PrintJob"获取所有打印作业。但是枚举所有printjob需要花费很多时间。还有其他方法可以枚举这些printjob.How我可以直接使用Win32 API来枚举这些printjob

//我用来获取所有printjob的代码片段,这会导致问题(很长时间)

string query =" SELECT * FROM Win32_PrintJob"

ManagementObjectsearcher search = new ManagementObjectsearcher (查询);

ManagementObjectCollection collection = search.Get();

帮我看看解决它。任何建议或解决方案对我都有很大的帮助。

谢谢,

解决方案

所需的时间取决于在任何给定时间连接的打印机上的内容。我使用的方法是创建一个ManagementEventWatcher,它允许您接收新到达的打印作业的异步通知,但您可能需要一种不同的方法,具体取决于您实际要对打印作业执行的操作。此代码构成了我正在构建的应用程序中的类的一部分,它监视打印机并要求最终用户确认打印作业并为每个Jop打印收费。

创建事件观察器结果

 

I use ManagementObjectSearcher class and using the query ,"SELECT * FROM Win32_PrintJob" to get all print job.But enumerating all printjob is taking lot of time.Is there any other ways to enumerate these printjob.How can i directly use the Win32 API to enumerate thses printjob

 

//code snippet which i am using to get all the printjob, and it's causing problem(taking a long time)

string query = "SELECT * FROM Win32_PrintJob"

ManagementObjectsearcher search = new ManagementObjectsearcher(query);

ManagementObjectCollection collection =  search.Get();

 

Help me to solve it out.Any suggestion or solution will be of great help for me.

Thanks,

 

解决方案

The time it takes will depend on how much stuff is on connected Printers at any given time.  The approach I use is to create a ManagementEventWatcher which allows you to receive Asynchronous notification of newly arrived Print Jobs, though you may need a different approach depending on what you actually want to do with the Print Jobs.  This code forms part of a class in an Application I'm building which Monitors Printers and required End Users to Confirm Print Jobs and Charges them for each Jop Printed.

Creating the Event Watcher

更多推荐

使用WMI查询“Win32

本文发布于:2023-11-06 06:44:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562971.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WMI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!