Get the total amount of pages from Win32_PrintJob

早过忘川 提交于 2020-01-21 03:48:05

问题


The Win32_PrintJob WMI class has lots of properties. (see: Win32_PrintJob on MSDN)

I have a small .NET application that poles the printing jobs and displays the jobs' information.

The TotalPages propery gives the amount of pages sent. But that figure DOESN'T take into account the number of copies requested by the user. So, if a user wants to print 5 copies of a two page document, the value of TotalPages will be 2, not 10.

How can i get the number of copies for a printing job, or get the total amount of pages to be printed (number of copies times number of pages in the job)?

Thanks


回答1:


i had the same problem with Win32_PrintJob (TotalPages/PagesPrinted doesn't take into account number of copies). I solved it by combining WMI with Win api.

Number of copies can be retrieved from DEVMODE structure (dmCopies) which is part of JOB_INFO_2 structure.

So you call GetJob with Level=2 and you will get JOB_INFO_2 instance. From there, it's piece of cake, just little bit of marshaling :).

Hope this helps.

Cheers,

Lukas



来源:https://stackoverflow.com/questions/7256737/get-the-total-amount-of-pages-from-win32-printjob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!