in my application (Windows 7, VS2010) i have to decrement a credit counter after successfully printing an image. Anyway, before starting the entire process, i\'d like to kno
You don't say what version of .Net you're using, but since .Net 3.0 there has been some good printing functionality. I've used this and whilst I can't be sure that it reports all kinds of status levels, I've certainly seen messages such as 'Toner Low' for various printers etc.
PrinterDescription is a custom class, but you can see the properties its using.
http://msdn.microsoft.com/en-us/library/system.printing.aspx
PrintQueueCollection printQueues = null;
List printerDescriptions = null;
// Get a list of available printers.
this.printServer = new PrintServer();
printQueues = this.printServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });
printerDescriptions = new List();
foreach (PrintQueue printQueue in printQueues)
{
// The OneNote printer driver causes crashes in 64bit OSes so for now just don't include it.
// Also redirected printer drivers cause crashes for some printers. Another WPF issue that cannot be worked around.
if (printQueue.Name.ToUpperInvariant().Contains("ONENOTE") || printQueue.Name.ToUpperInvariant().Contains("REDIRECTED"))
{
continue;
}
string status = printQueue.QueueStatus.ToString();
try
{
PrinterDescription printerDescription = new PrinterDescription()
{
Name = printQueue.Name,
FullName = printQueue.FullName,
Status = status == Strings.Printing_PrinterStatus_NoneTxt ? Strings.Printing_PrinterStatus_ReadyTxt : status,
ClientPrintSchemaVersion = printQueue.ClientPrintSchemaVersion,
DefaultPrintTicket = printQueue.DefaultPrintTicket,
PrintCapabilities = printQueue.GetPrintCapabilities(),
PrintQueue = printQueue
};
printerDescriptions.Add(printerDescription);
}
catch (PrintQueueException ex)
{
// ... Logging removed
}
}