Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Knowledge Base > Code Library > Cancel a print job by printer name/job id


Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2003, 06:02 AM
Merrion's Avatar
Merrion Merrion is offline
Ultimate Contributor

* Guru *
 
Join Date: Sep 2001
Location: Dublin, Ireland
Posts: 1,828
Default Cancel a print job by printer name/job id


Code:
Option Explicit Private Type PRINTER_DEFAULTS pDatatype As String pDevMode As Long DesiredAccess As Long End Type 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 ClosePrinter Lib "winspool.drv" _ (ByVal hPrinter As Long) As Long Public Enum PrinterAccessRights PRINTER_ACCESS_ADMINISTER = &H4 PRINTER_ACCESS_USE = &H8 PRINTER_ALL_ACCESS = &HF000C End Enum Private Declare Function SetJob Lib "winspool.drv" Alias _ "SetJobA" (ByVal hPrinter As Long, _ ByVal JobId As Long, _ ByVal Level As Long, _ pJob As Long, _ ByVal Command As Long) As Long Public Enum PrintJobControlCommands JOB_CONTROL_PAUSE = 1 JOB_CONTROL_RESUME = 2 JOB_CONTROL_CANCEL = 3 JOB_CONTROL_RESTART = 4 JOB_CONTROL_DELETE = 5 JOB_CONTROL_SENT_TO_PRINTER = 6 JOB_CONTROL_LAST_PAGE_EJECTED = 7 End Enum Public Sub KillPrintJob(ByVal PrinterDeviceName As String, ByVal idJob As Long) Dim lRet As Long Dim mhPrinter As Long Dim paAll As PRINTER_DEFAULTS paAll.DesiredAccess = PRINTER_ALL_ACCESS Call OpenPrinter(PrinterDeviceName, mhPrinter, paAll) If mhPrinter <> 0 Then lRet = SetJob(mhPrinter, idJob, 0, 0, JOB_CONTROL_DELETE) Call ClosePrinter(mhPrinter) End If End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Print a form in Specific Printer (not to the default) brakos General 2 07-29-2003 07:53 PM
Printing to two different printers in vb 6.0 tg35 General 4 05-22-2003 11:05 AM
Print dialog - problem resetting printer to default Curban General 3 04-29-2003 12:57 PM
why does my code no longer work dapul General 4 11-07-2002 06:22 PM
CAN SOMEONE TELL ME HOW TO????? Bunkey23 General 6 11-24-2000 01:37 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->