[access报表]获得某一台网络打印机有几份等待打印的报表
时 间:2008-09-04 08:11:37
作 者:fan0217 ID:3202 城市:绵阳
摘 要:获得某一台网络打印机有几份等待打印的报表
正 文:
CODE:
'Constants Definition
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const PRINTER_ACCESS_ADMINISTER = &H4
Public Const PRINTER_ACCESS_USE = &H8
'Types Definition
Public Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As DEVMODE
DesiredAccess As Long
End Type
'API Declarations
Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _
(ByVal pPrinterName As String, phPrinter As Long, _
pDefault As PRINTER_DEFAULTS) As Long
Public Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" _
(ByVal HPrinter As Long, ByVal FirstJob As Long, ByVal NoJobs As Long, _
ByVal Level As Long, pJob As Byte, ByVal cdBuf As Long, _
pcbNeeded As Long, pcReturned As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'取得指定的打印机,目前有多少 Jobs (最大值为 128)
'打印机的名称可以是 mapping 的网络路径名称,例如: "\\myserver\myprinter"
'测试预设打印机的 Queue(Printer.DeviceName)
'MsgBox "打印机中尚有 " & GetPrinterQueue(Printer.DeviceName) & " 份报表", 64, "讯息"
Function GetPrinterQueue(PrinterName As String) As Long
Dim PrinterStruct As PRINTER_DEFAULTS
Dim HPrinter As Long
Dim ret As Boolean
Dim JobStruct(0 To 127) As Byte
Dim pcbNeeded As Long
Dim pcReturned As Long
Dim TempByte As Byte
'设定 Printer structure 初值
PrinterStruct.pDatatype = vbNullString
PrinterStruct.pDevMode.dmSize = Len(PrinterStruct.pDevMode)
PrinterStruct.DesiredAccess = PRINTER_ACCESS_USE
'取得打印机的 Handle
ret = OpenPrinter(PrinterName, HPrinter, PrinterStruct)
'取得打印机的 active jobs
ret = EnumJobs(HPrinter, 0, 127, 1, TempByte, 0, pcbNeeded, pcReturned)
If pcbNeeded = 0 Then
GetPrinterQueue = 0
Else
ret = EnumJobs(HPrinter, 0, 127, 1, JobStruct(0), pcbNeeded, pcbNeeded, pcReturned)
GetPrinterQueue = pcReturned
End If
'关闭打印机
ret = CloseHandle(HPrinter)
End Function
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access快速开发平台企业版--...(11.18)
- 不会用多表联合查询,多表查询没结果...(11.16)
- 【案例分享】主键字段值含有不间断空...(11.16)
- Access快速开发平台--后台D...(11.14)
- 微软Access邀测新Monaco...(11.12)
- Access列表框左右互选、列表框...(11.11)
- 高效率在导入数据前删除记录(11.10)
- Access报价单转订单示例代码(11.08)
- Access系统自带的日期选择器不...(11.08)
- 分享一下Access工程中的acw...(11.07)