Following this question: How do I retrieve a list or number of jobs from a printer queue?
I'm still stuck on how to target a specific printer of which I currently only know the name using the LocalPrintServer class. The application is supposed to print to several machines at once and all printspoolers need to be monitored separately. Can anyone provide me with a code snippet that shows how I can instantiate a LocalPrintServer object using only the name of the printer?
Thanks in advance!
Edit: Added code fragment of solution:
private int GetNumberOfPrintJobs()
{
LocalPrintServer server = new LocalPrintServer();
PrintQueueCollection queueCollection = server.GetPrintQueues();
PrintQueue printQueue = null;
foreach (PrintQueue pq in queueCollection)
{
if (pq.FullName == PrinterName) //PrinterName is a classmember
printQueue = pq;
}
int numberOfJobs = 0;
if (printQueue != null)
numberOfJobs = printQueue.NumberOfJobs;
return numberOfJobs;
}
That wasn't so hard after all!