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.