Read printer pool to get number of pages being printed
I have a network printer in the classroom lab. I'd like to keep record of how many pages of each student has printed. I want to know how can I read the printer pool to get the number of pages, when a student prints. Here开发者_JS百科's what I have in mind: Write a Windows service to get:
- User logged in name
- Number of printed everytime they print the docs
- Send username + number of pages to remote database
What I don't know:
- how to get number of pages every time they print
If possible I'd like to see this done in VB.NET.
Thanks.
You can use the WMI class Win32_PrintJob to get out information about each job. It has properties called PagesPrinted
and TotalPages
which would hopefully give you what you need. It also has other properties like Status
that might also be relevant (if you don't want to count pages in deleted or failed jobs or similar).
This article has information about calling this class from VB.Net:
Interrogating your Printer Queries with WMI
Just remember to add a reference to System.Management
since that's not added by default to a new project.
精彩评论