开发者

Get the total amount of pages from Win32_PrintJob

开发者 https://www.devze.com 2023-04-01 04:57 出处:网络
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 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开发者_Go百科 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号