如何取得当前系统打印机的纸张大小??????

llmmhh 2001-12-13 09:49:28
Who can help me ???
...全文
51 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxlroad 2002-01-22
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/Topic/463/463443.shtm
你如果看懂了可以告诉我吗 qq:26603030 请说是:CSDN的朋友
我对将papersize和papername对应起来呢?例如papersize=9,对应的papername为A4. 还是得不到 例如papersize=9

Option Explicit

Private Const DC_PAPERNAMES = 16
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
'http://www.csdn.net/expert/Topic/463/463443.shtm
Private Sub Form_Load()
Dim i As Integer
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Ret As Long, PaperSizes() As Byte, Cnt As Long, AllNames As String
Dim lStart As Long, lEnd As Long
'Retrieve the number of available paper names
Ret = DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERNAMES, ByVal 0&, ByVal 0&)
'resize the array
ReDim PaperSizes(1 To Ret * 64) As Byte
'retrieve all the available paper names
Call DeviceCapabilities(Printer.DeviceName, "LPT1", DC_PAPERNAMES, PaperSizes(1), ByVal 0&)
'set the form's graphic mode to persistent
Me.AutoRedraw = True
Me.Print "Supported papersizes:"
'convert the retrieved byte array to a string
AllNames = StrConv(PaperSizes, vbUnicode)
'loop through the string and search for the names of the papers
Do
lEnd = InStr(lStart + 1, AllNames, Chr$(0), vbBinaryCompare)
If (lEnd > 0) And (lEnd - lStart - 1 > 0) Then
'Combo1.AddItem Mid$(AllNames, lStart + 1, lEnd - lStart - 1)
Me.Print Mid$(AllNames, lStart + 1, lEnd - lStart - 1)
'Me.Print AllNames
End If
lStart = lEnd
Loop Until lEnd = 0
End Sub

7,763

社区成员

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

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