How can I monitor print jobs for a printer?

I am currently researching to develop an application that that monitors print jobs queueing to a particular printer, coming from various workstations, each having a different user.  I need to monitor the userid of every user sending print jobs to the printer as well as the number of pages being sent.

Any help with pointing me at the right direction for a good start is appreciated.

Thanks
b0rnslipyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TrefrobbertCommented:
well printer usually have a good support for snmp, so I think you have to work in that direction.
have a look at this post
http://blog.crowe.co.nz/archive/2005/08/08/182.aspx
0
Mikael JanssonCommented:
I would recommend to go down another path and use WMI to subscribe to events, then you will get information about printjobs including UserID, document name, pages printed, total pages, size etc. I am developing an application like that as well that can be running remotely.
You should use something called System.Management.ManagementEventWatcher where you define a query that will subscribe to any event regarding a printjob Create, Modify, delete. A query could look like this
SELECT * FROM __InstanceOperationEvent WITHIN 0.5 WHERE TargetInstance ISA "Win32_PrintJob"
There are different things you can subscribe to and whats interesting to use here is
__InstanceCreateEvent  (When a printjob is created)
__InstanceModifiedEvent (When a printjob changes)
__InstanceDeletionEvent (When a printjob is deleted/removed)
__InstanceOperationEvent (includes all three above and you have to look what type it is)
These WMI queries can be used to get event triggers for at least all Win32_ classes in CimV2, that includes, Processes, printers etc.



Look at these webpages for more info about the WMI usage
__InstanceCreateEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394649(VS.85).aspx
 
__InstanceModifiedEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394651(VS.85).aspx

__InstanceDeletionEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394650(VS.85).aspx
__InstanceOperationEvent (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/aa394652(VS.85).aspx

WMI Classes (Win32)
http://msdn.microsoft.com/en-us/library/aa394084(VS.85).aspx
System.Management.ManagementEventWatcher (Microsoft MSDN)
http://msdn.microsoft.com/en-us/library/system.management.managementeventwatcher(VS.80).aspx
Below is a code snippet of how to use the ManagementEventWatcher, it is just an excerpt from my code so its not complete, but I hope you get a point of how to use it.
Good luck!
/ Mikael

// Declaration
mWatcher = new ManagementEventWatcher(); 
mWatcher.Scope = new ManagementScope("\\\\" + strComputerName + "\\root\\CIMV2"); 
// you can play around with the WITHIN interval but it costs performance if using faster intervals
string oQuery = "SELECT * FROM __InstanceOperationEvent WITHIN 0.1 WHERE TargetInstance ISA \"Win32_PrintJob\""; 
mWatcher.Query = new EventQuery(oQuery); 
mWatcher.EventArrived += new EventArrivedEventHandler(mWatcher_EventArrived); 
mWatcher.Stopped += new StoppedEventHandler(mWatcher_Stopped); 

Open in new window

0
Mikael JanssonCommented:
Forgot to tell that the computername in this case is the printserver where the printqueues are installed (not the clients printing)
/ Mikael
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mikael JanssonCommented:
The solution I have suggested (last post before admin post) provides exacly the functionality that the author asked for,  also provided a code example, so its a sad that the the effort taken is left  unnoticed.
br
/ Mikael
 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.