C#PrintDocument和打印机状态 [英] C# PrintDocument and Printer Status
本文介绍了C#PrintDocument和打印机状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下代码获取PointOfSale打印机的打印机状态:
I am trying to get the printer status of a PointOfSale printer using the following code:
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);
}
}
}
}
问题是,即使拔掉电源或缺纸,状态也可能是3(空闲)或4(正在打印).
Problem is, the status is either 3 (idle) or 4(printing), even when unplugged or the paper is out.
我已经阅读了很多有关此问题的文章,但没有找到答案.这样对吗?我还要如何检查状态?感谢您的帮助.
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.
这篇关于C#PrintDocument和打印机状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文