如何通过VB.net检查打印机的纸张状态 [英] How to do check paper status of printer through VB.net

查看:72
本文介绍了如何通过VB.net检查打印机的纸张状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我是Windows应用程序的新手.

我已经申请了打印薪水证明的信息亭应用程序,该应用程序已经上线了.

现在他们已经提出了一些要求.
1)如果应用程序由于任何原因被关闭,它应该会自动再次打开,并且用户将无法执行其他任何操作.
2)如果打印机中没有纸张,则应通知用户不存在纸张.
3)机器是触摸屏,一些用户通过连续单击中断该过程,然后应用程序关闭,如何防止这种情况.

如果您有解决这些问题的想法,请提供帮助.

在此先感谢
-Sanju

Dear Friends,

I am new in windows application.

I have made a Kiosk application for printing salary certificate and it has gone live.

Now they have asked some ammendments they are.
1) If the application gets closed for any reason it should automatically open again and user should not be able to do anything else.
2) If there is no paper in printer the user should be informed that no paper exist.
3) The machine is a touch screen some users interrupts the process by continously clicking and the application gets close, how to prevent this.

Please help if you have any idea in over coming these issues.

Thanks In Advance
-Sanju

推荐答案

这里是获取打印机状态和状态的一种方法(状态也包括您要查找的项目)

查看源代码
打印吗?

作为Hashtable的公共共享函数GetPrinterProperties()
作为Hashtable的Dim属性= New Hashtable()
昏暗的搜索者,作为ManagementObjectSearcher =新的ManagementObjectSearcher("SELECT * FROM Win32_Printer")

''现在循环遍历搜索器中的所有对象
昏暗的obj作为ManagementObject
对于每个obj函数searcher.Get()为In
其他",未知",空闲",打印",热身",停止打印",脱机"
最终功能

string()printerState = {已暂停",错误",待删除",卡纸",缺纸",手动进纸",纸张问题",脱机","IO活动",忙" ,"印刷,
出纸槽已满",不可用",等待",正在处理",初始化",预热",碳粉不足",无碳粉",页面平底",需要用户干预",
内存不足",门打开",服务器未知",省电"
}

''现在遍历所有属性
将Dim数据作为PropertyData
对于obj.Properties中的每个数据
''确保我们拥有默认打印机
如果CType(obj("Default"),Boolean)然后
选择案例数据.Name.ToLower()
案例"printerstate"
properties.Add("State",printerState(Convert.ToInt32(data.Value)))
退出
案例"printerstatus"
properties.Add(状态",printerStatus(Convert.ToInt32(data.Value)))
退出
结束选择
如果结束
下一个

返回属性
下一个
结束功能
Here is one method to get the status and state of the printer (status includes the items you are looking for as well)

view source
print?

Public Shared Function GetPrinterProperties() As Hashtable
Dim properties As Hashtable = New Hashtable()
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_Printer")

''now loop thorugh all the objects in the searcher
Dim obj As ManagementObject
For Each obj Function searcher.Get() As In
"Other", "Unknown", "Idle", "Printing", "WarmUp", "Stopped Printing", "Offline"
End Function

string() printerState = {"Paused","Error","Pending Deletion","Paper Jam","Paper Out","Manual Feed","Paper Problem", "Offline","IO Active","Busy","Printing",
"Output Bin Full","Not Available","Waiting", "Processing","Initialization","Warming Up","Toner Low","No Toner","Page Punt", "User Intervention Required",
"Out of Memory","Door Open","Server_Unknown","Power Save"
}

''now loop through all the properties
Dim data As PropertyData
For Each data In obj.Properties
''make sure we have the default printer
If CType(obj("Default"),Boolean) Then
Select Case data.Name.ToLower()
Case "printerstate"
properties.Add("State", printerState(Convert.ToInt32(data.Value)))
Exit For
Case "printerstatus"
properties.Add("Status", printerStatus(Convert.ToInt32(data.Value)))
Exit For
End Select
End If
Next

Return properties
Next
End Function


这篇关于如何通过VB.net检查打印机的纸张状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆