VB,Open "LPT1:"控制打印机,怎么检测打印机状态
VB,Open "LPT1:"控制打印机,如何检测打印机状态?
Windows 2000 和 Windows XP环境下
dim intFile as integer
intfile=freefile
open "LPT1: " for output as #intFile
print #intFile, "TEST STRING "
Close #intFile
由于没有打印机(微打)驱动,只好用如上这种办法控制,但在打印机没开,或者故障的时候,程序到Close就会死掉,请问如何在Close之前获得打印机的状态?或者不管是否打印成功,只要不死机就行。谢谢。
另,好像win9x的BIOS中断 int 21h可以得到这些状态,不知道win2k&winXP是否仍然支持BIOS中断,另外不知道BIOS中断在vb中的具体用法:(( 谁能给个例子?谢谢
------解决方案--------------------
Public Function DoesPrinterExist() As Boolean '判断是否有打印机
On Error GoTo HandleError
Dim o_prnItem As Printer
Dim o_blnRet As Boolean
o_blnRet = False
For Each o_prnItem In Printers
If Not (o_prnItem.DeviceName Like "%传真% ") Then
o_blnRet = True
Exit For
Else
o_blnRet = False
End If
Next
DoesPrinterExist = o_blnRet
Exit Function
HandleError:
DoesPrinterExist = False
End Function
Windows 2000 和 Windows XP环境下
dim intFile as integer
intfile=freefile
open "LPT1: " for output as #intFile
print #intFile, "TEST STRING "
Close #intFile
由于没有打印机(微打)驱动,只好用如上这种办法控制,但在打印机没开,或者故障的时候,程序到Close就会死掉,请问如何在Close之前获得打印机的状态?或者不管是否打印成功,只要不死机就行。谢谢。
另,好像win9x的BIOS中断 int 21h可以得到这些状态,不知道win2k&winXP是否仍然支持BIOS中断,另外不知道BIOS中断在vb中的具体用法:(( 谁能给个例子?谢谢
------解决方案--------------------
Public Function DoesPrinterExist() As Boolean '判断是否有打印机
On Error GoTo HandleError
Dim o_prnItem As Printer
Dim o_blnRet As Boolean
o_blnRet = False
For Each o_prnItem In Printers
If Not (o_prnItem.DeviceName Like "%传真% ") Then
o_blnRet = True
Exit For
Else
o_blnRet = False
End If
Next
DoesPrinterExist = o_blnRet
Exit Function
HandleError:
DoesPrinterExist = False
End Function