VB,Open "LPT1:"控制打印机,如何检测打印机状态?

wuxicys 2007-05-23 04:32:25
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中的具体用法:(( 谁能给个例子?谢谢
...全文
748 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuxicys 2007-05-29
  • 打赏
  • 举报
回复
已解决:

使用了WinIo (http://www.internals.com/) 中的GetPortVal 判断得到的值就可以了.

我这个打印机是用的&h379端口,

win2k,winxp 测试通过.
wyj4862 2007-05-24
  • 打赏
  • 举报
回复
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
wuxicys 2007-05-24
  • 打赏
  • 举报
回复
没有人知道吗? 谢谢。
wuxicys 2007-05-24
  • 打赏
  • 举报
回复
或者用其他编程语言,

大家给个方案就可以,谢谢。
wuxicys 2007-05-24
  • 打赏
  • 举报
回复
to wyj:
谢谢,但这样不行。Windows下根本看不到这个设备,没有驱动,我只是王LPT1输出东西。
Printers里没有这个设备。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧