C# PrintDocument and Printer Status

对着背影说爱祢 提交于 2019-12-23 10:56:43

问题


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);
      }
    }
  }
}

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.


回答1:


What Brand of printer are you using?

Sometimes the Brand will have a specific command you can send to query the status.



来源:https://stackoverflow.com/questions/7324887/c-sharp-printdocument-and-printer-status

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!