[英]C# PrintDocument and Printer Status
I am trying to get the printer status of a PointOfSale printer using the following code: 我试图使用以下代码获取PointOfSale打印机的打印机状态:
Hashtable properties = new Hashtable();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win2_Printer");
foreach (ManagementObject obj in searcher.Get()) {
if (obj["name"].ToString() == printerName) {
foreach (PropertyData data in obj.Properties) {
if(data.Name.ToLower() = "printerstatus") {
int printerStatus = Convert.ToInt32(data.Value);
}
}
}
}
Problem is, the status is either 3 (idle) or 4(printing), even when unplugged or the paper is out. 问题是,状态是3(空闲)或4(打印),即使拔下插头或纸张已用完。
I have read a lot of posts with this same issue, but have not found an answer. 我已经阅读了很多相同问题的帖子,但还没有找到答案。 Is this correct?
这个对吗? How else would I check the status?
我怎么检查状态? Any help is appreciated.
任何帮助表示赞赏。
What Brand of printer are you using? 你使用什么牌子的打印机?
Sometimes the Brand will have a specific command you can send to query the status. 有时,Brand会有一个特定的命令,您可以发送该命令来查询状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.