C# PrintDocument 和打印机状态
我正在尝试使用以下代码获取 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);
}
}
}
}
问题是,即使拔掉插头或纸张已用完,状态也为 3(空闲)或 4(正在打印)。
我读过很多关于同样问题的帖子,但没有找到答案。这是正确的吗?我还能如何检查状态?任何帮助表示赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用什么品牌的打印机?
有时,品牌会有一个特定的命令,您可以发送该命令来查询状态。
What Brand of printer are you using?
Sometimes the Brand will have a specific command you can send to query the status.