Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Jobs

Status
Not open for further replies.

dwhitlow

MIS
Mar 1, 2000
40
US
Is there a way to delete jobs from the print queue, either selectively or all of them? I am able to populate a ListView box with all the print jobs in the queue for a certain printer, but I need to be able to delete them also. Any ideas?
 
Hi dwhitlow
code given below is for "Get the Number of Waiting Jobs of a specified Printer on your network"... study this and implement further.

Shirin Saxena
----------------------------------------
Option Explicit

'Constants Definition
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8

'Types Definition
Private 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

Private Type PRINTER_DEFAULTS
pDatatype As String
pDevMode As DEVMODE
DesiredAccess As Long
End Type

'API Declarations
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As _
Long, pDefault As PRINTER_DEFAULTS) As Long

Private 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

Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
------------------------------------------------

Function GetPrinterQueue(PrinterName As String) As Long

On Error GoTo errorhandler
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

'Initialize the Printer structure
PrinterStruct.pDatatype = vbNullString
PrinterStruct.pDevMode.dmSize = Len(PrinterStruct.pDevMode)
PrinterStruct.DesiredAccess = PRINTER_ACCESS_USE
'Get the printer Handle
ret = OpenPrinter(PrinterName, HPrinter, PrinterStruct)
'Get the Printer 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
'Close printer
ret = CloseHandle(HPrinter)

Exit Function

errorhandler:
Exit Function

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top