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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving prints jobs between printer queues

Status
Not open for further replies.

Uniquex

Programmer
Dec 16, 2002
15
SG
Hi people,

I am using VB 6 in a NT/Xp/Me/W2K environment .

Q1 :
I need to move print jobs from one print queue to another, Moving from local to local/ local to LAN printer queues that use different drivers. How do I do that? What functions/APIs I need to use?
I already know how to get printer and print jobs information from the print queues using WIN32 API functions, the only problem is how to move print jobs across print queues

i.e Print queue 1(HP driver) --> directly to --> (Network) Print queue 2(Epson driver)

Q2: :
Are printer spool files generated in relation/containing information about the printer drivers used to spool it?

i.e. If I send a spool file generated by Print Queue 1(HP driver) to Print Queue 2(Epson driver) directly to print. Will error occur?
 

The only way I can think of doing this is to capture the EMF, cancel the existing and then submit the EMF to the other printer. I doubt that this will work very well and working in VB may be harder than using C/C++.

Good Luck

 
Hi vb5pgrmr,

Can you teach me how to do what you have proposed?
I am quite new to all these..

thanks
 

Here is a start at what you will need. From here I will still suggest you get into some system level programming with C/C++.

[tt]
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Const DEFAULT_VALUES = 0

Private Const PRINTER_CONTROL_PAUSE = 1
Private Const PRINTER_CONTROL_PURGE = 3
Private Const PRINTER_CONTROL_RESUME = 2
Private Const PRINTER_CONTROL_SET_STATUS = 4

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

Private Const DC_BINADJUST = 19
Private Const DC_BINNAMES = 12
Private Const DC_BINS = 6
Private Const DC_COLLATE = 22
Private Const DC_COPIES = 18
Private Const DC_DATATYPE_PRODUCED = 21
Private Const DC_DRIVER = 11
Private Const DC_DUPLEX = 7
Private Const DC_EMF_COMPLIANT = 20
Private Const DC_ENUMRESOLUTIONS = 13
Private Const DC_EXTRA = 9
Private Const DC_FIELDS = 1
Private Const DC_FILEDEPENDENCIES = 14
Private Const DC_HASDEFID = &H534 '0x534B
Private Const DC_MAXEXTENT = 5
Private Const DC_MINEXTENT = 4
Private Const DC_ORIENTATION = 17
Private Const DC_PAPERNAMES = 16
Private Const DC_PAPERS = 2
Private Const DC_PAPERSIZE = 3
Private Const DC_SIZE = 8
Private Const DC_TRUETYPE = 15
Private Const DC_VERSION = 10

Private Const DMBIN_UPPER = 1
Private Const DMBIN_AUTO = 7
Private Const DMBIN_CASSETTE = 14
Private Const DMBIN_ENVELOPE = 5
Private Const DMBIN_ENVMANUAL = 6
Private Const DMBIN_FIRST = DMBIN_UPPER
Private Const DMBIN_LARGECAPACITY = 11
Private Const DMBIN_LARGEFMT = 10
Private Const DMBIN_LAST = DMBIN_CASSETTE
Private Const DMBIN_LOWER = 2
Private Const DMBIN_MANUAL = 4
Private Const DMBIN_MIDDLE = 3
Private Const DMBIN_ONLYONE = 1
Private Const DMBIN_SMALLFMT = 9
Private Const DMBIN_TRACTOR = 8
Private Const DMBIN_USER = 256 ' device specific bins start here

Private Type ACL
AclRevision As Byte
Sbz1 As Byte
AclSize As Integer
AceCount As Integer
Sbz2 As Integer
End Type

Private Type SECURITY_DESCRIPTOR
Revision As Byte
Sbz1 As Byte
Control As Long
Owner As Long
Group As Long
Sacl As ACL
Dacl As ACL
End Type

Private Type PRINTER_INFO_2
pServerName As String
pPrinterName As String
pShareName As String
pPortName As String
pDriverName As String
pComment As String
pLocation As String
pDevMode As DEVMODE
pSepFile As String
pPrintProcessor As String
pDatatype As String
pParameters As String
pSecurityDescriptor As SECURITY_DESCRIPTOR
Attributes As Long
Priority As Long
DefaultPriority As Long
StartTime As Long
UntilTime As Long
Status As Long
cJobs As Long
AveragePPM As Long
End Type

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

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 GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _
(ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long

Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" _
(ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Byte, ByVal Command As Long) As Long

Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
Alias "DeviceCapabilitiesA" (ByVal lpsDeviceName As String, _
ByVal lpPort As String, ByVal iIndex As Long, lpOutput As Any, _
ByVal lpDevMode As Long) As Long
[/tt]

Good Luck

 
HI vb5pgrmr,

I really appreciate your help! thanks..

may i ask a few more questions about your code.. i am already using some of the APIs you listed..

but i can't figure out which API does
- capture the EMF
- submit the EMF to the other printer

is it possible to submit print emf jobs using CopyMemory()?

I don't expect you to write me the codes, just tell me which APIs should i use to do the above 2..

thank you in advance!

 
To capture the EMF we outsourced the project and it is written in C and I have not seen it for awhile so I am clueless for that part (not at work now so code is not available (on this computer)). Also, our code only modifies the EMF so I do not know about how to move it. I am guessing that with enough research at MS (I belive I remember something ...

Ahh yes, here are a few links for you ...

*
*

* = best bets for info overload

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top