internal: // Check for possible trouble states of a printer using the flags of the QueueStatus property static void SpotTroubleUsingQueueAttributes (System::String^% statusReport, System::Printing::PrintQueue^ pq) { if ((pq->QueueStatus & PrintQueueStatus::PaperProblem) == PrintQueueStatus::PaperProblem) { statusReport = statusReport + "Has a paper problem. "; } if ((pq->QueueStatus & PrintQueueStatus::NoToner) == PrintQueueStatus::NoToner) { statusReport = statusReport + "Is out of toner. "; } if ((pq->QueueStatus & PrintQueueStatus::DoorOpen) == PrintQueueStatus::DoorOpen) { statusReport = statusReport + "Has an open door. "; } if ((pq->QueueStatus & PrintQueueStatus::Error) == PrintQueueStatus::Error) { statusReport = statusReport + "Is in an error state. "; } if ((pq->QueueStatus & PrintQueueStatus::NotAvailable) == PrintQueueStatus::NotAvailable) { statusReport = statusReport + "Is not available. "; } if ((pq->QueueStatus & PrintQueueStatus::Offline) == PrintQueueStatus::Offline) { statusReport = statusReport + "Is off line. "; } if ((pq->QueueStatus & PrintQueueStatus::OutOfMemory) == PrintQueueStatus::OutOfMemory) { statusReport = statusReport + "Is out of memory. "; } if ((pq->QueueStatus & PrintQueueStatus::PaperOut) == PrintQueueStatus::PaperOut) { statusReport = statusReport + "Is out of paper. "; } if ((pq->QueueStatus & PrintQueueStatus::OutputBinFull) == PrintQueueStatus::OutputBinFull) { statusReport = statusReport + "Has a full output bin. "; } if ((pq->QueueStatus & PrintQueueStatus::PaperJam) == PrintQueueStatus::PaperJam) { statusReport = statusReport + "Has a paper jam. "; } if ((pq->QueueStatus & PrintQueueStatus::Paused) == PrintQueueStatus::Paused) { statusReport = statusReport + "Is paused. "; } if ((pq->QueueStatus & PrintQueueStatus::TonerLow) == PrintQueueStatus::TonerLow) { statusReport = statusReport + "Is low on toner. "; } if ((pq->QueueStatus & PrintQueueStatus::UserIntervention) == PrintQueueStatus::UserIntervention) { statusReport = statusReport + "Needs user intervention. "; } // Check if queue is even available at this time of day // The method below is defined in the complete example. ReportAvailabilityAtThisTime(statusReport, pq); };
若要使用每个属性来检查打印机状态,只需读取每个属性,如果该属性为 true,则在最终报告中添加一个将呈现给用户的说明 (下面将讨论在该代码末尾处调用的ReportAvailabilityAtThisTime方法)。