打印机状态的读取,为何我的不行?

seeQe 2004-12-20 01:36:11
代码如下:
Dim bPrinterInfo2() As Byte
Dim hPrinter As Long
Dim lResult As Long
Dim BytesNeeded As Long, BytesUsed As Long
Dim pd As PRINTER_DEFAULTS
Dim m_pi2 As PrinterInfo2

If OpenPrinter(Printer.DeviceName, hPrinter, pd) = 0 Then Exit Function
Call GetPrinter(hPrinter, 2, 0, 0, BytesNeeded)
ReDim bPrinterInfo2(0 To BytesNeeded - 1) As Byte

lResult = GetPrinter(hPrinter, 2, bPrinterInfo2(0), BytesNeeded, BytesUsed)
Call CopyMemory(m_pi2.Attributes, bPrinterInfo2(52), 32)

If m_pi2.Attributes And PRINTER_ATTRIBUTE_NETWORK > 0 Then '这个正确的
MsgBox "a network printer."
End If

Call CopyMemory(m_pi2.Status, bPrinterInfo2(72), 4) '这个是错误的

以上代码中,能读到打印机的某些状态,但我始终无法读得它的"在线与否,缺纸"等状态
为什么? 请指点了.


其中:
Public Type PrinterInfo2
pServerName As String
pPrinterName As String
pShareName As String
pPortName As String
pDriverName As String
pComment As String
pLocation As String
pDevMode As Long 'DEVMODE
pSepFile As String
pPrintProcessor As String
pDatatype As String
pParameters As String
pSecurityDescriptor As Long 'SECURITY_DESCRIPTOR
Attributes As Long '52
Priority As Long '56
DefaultPriority As Long '60
StartTime As Long '64
UntilTime As Long '68
Status As Long '72
cJobs As Long '76
AveragePPM As Long '80
End Type















...全文
106 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
seeQe 2004-12-22
  • 打赏
  • 举报
回复
是不是没有做过呢,大家编程序都不用检测打印机在线与否就往打印机里面发文档数据吗?
seeQe 2004-12-21
  • 打赏
  • 举报
回复
up 自我支持一下了
seeQe 2004-12-20
  • 打赏
  • 举报
回复
我的方法和PrnInfo.zip 中的方法是一致的,可是都没有获得打印机的状态,请支持
lxcc 2004-12-20
  • 打赏
  • 举报
回复
cc:
http://www.mvps.org/vb/code/PrnInfo.zip
wwqna 2004-12-20
  • 打赏
  • 举报
回复
顶一下

7,785

社区成员

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

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