怎样才能得到打印机的纸张来源???(高分:100分)

cdwq88 2003-05-10 12:18:40
怎样才能得到打印机的纸张来源???
...全文
116 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdwq88 2003-05-12
  • 打赏
  • 举报
回复
纸张来源,我是说怎样才能得到打印机的纸张来源是手动进张,自动选择等。
leonnet 2003-05-10
  • 打赏
  • 举报
回复
一楼的哥们是个热心肠
lihonggen0 2003-05-10
  • 打赏
  • 举报
回复
获取打印机纸张信息



Option Explicit
Private Const DC_MAXEXTENT = 5
Private Const DC_MINEXTENT = 4
Private Const DC_PAPERNAMES = 16
Private Const DC_PAPERS = 2
Private Const DC_PAPERSIZE = 3
Private Declare Function DeviceCapabilities Lib "winspool.drv" Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, lpDevMode As Any) As Long
Private Type POINTS
x As Long
y As Long
End Type

'***********************************************************
'* 名称:GetPaperInfo
'* 功能:得到打印机低张信息
'* 用法:GetPaperInfo(控件名)
'* 描述:如在 form_load()中调用GetPaperInfo MSHFlexGrid1
'***********************************************************
Public Function GetPaperInfo(Flex As MSHFlexGrid) As Boolean

Dim i As Long, ret As Long
Dim Length As Integer, Width As Integer
Dim PaperNo() As Integer, PaperName() As String, PaperSize() As POINTS

With Flex
.FormatString = "^纸张编号|^纸张名称|^纸张长度|^纸张宽度"
For i = 0 To .Cols - 1
.ColWidth(i) = 1700
Next i
.AllowUserResizing = flexResizeColumns
.Left = 0
End With

'支持最大打印纸:
ret = DeviceCapabilities(Printer.DeviceName, "LPT1", DC_MAXEXTENT, ByVal 0&, ByVal 0&)
Length = ret \ 65536
Width = ret - Length * 65536

'支持最小打印纸:
ret = DeviceCapabilities(Printer.DeviceName, "LPT1", DC_MINEXTENT, ByVal 0&, ByVal 0&)
Length = ret \ 65536
Width = ret - Length * 65536

'支持纸张种类数
ret = DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERS, ByVal 0&, ByVal 0&)

'纸张编号
ReDim PaperNo(1 To ret) As Integer
Call DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERS, PaperNo(1), ByVal 0&)

'纸张名称
Dim arrPageName() As Byte
Dim allNames As String
Dim lStart As Long, lEnd As Long
ReDim PaperName(1 To ret) As String
ReDim arrPageName(1 To ret * 64) As Byte
Call DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERNAMES, arrPageName(1), ByVal 0&)
allNames = StrConv(arrPageName, vbUnicode)
'loop through the string and search for the names of the papers
i = 1
Do
lEnd = InStr(lStart + 1, allNames, Chr$(0), vbBinaryCompare)
If (lEnd > 0) And (lEnd - lStart - 1 > 0) Then
PaperName(i) = Mid$(allNames, lStart + 1, lEnd - lStart - 1)
i = i + 1
End If
lStart = lEnd
Loop Until lEnd = 0

'纸张尺寸

ReDim PaperSize(1 To ret) As POINTS
Call DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERSIZE, PaperSize(1), ByVal 0&)

'显示在表格中
For i = 1 To ret
Flex.AddItem PaperNo(i) & vbTab & PaperName(i) & vbTab & PaperSize(i).y & vbTab & PaperSize(i).x
Next i

End Function

807

社区成员

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

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