WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Printer Controller

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Broadcasting Printer Port Change

Keywords: 	  Broadcasting Printer Port Change

Question:

I am trying to change the printer port on the fly, say from LPT1: to \\server\queue, but none of the DllCall examples work, I've tried DMC=27 and WININICHG=26 and the SendMessageA DllCall examples, but it doesn't work, any ideas....?

changing the default printer is easy, but I can't get the port changes to stick...

Answer:

It's actually pretty simple using the Printer Extender after all...
; Print control extender
AddExtender("WWPRT34I.DLL")

; current printer
prnt="HP LaserJet 4 on HO1244LN"

; port we want to change it to.
newport="\\txhomit02\ho0642lm"

; name of print driver, (i.e. 'HP LaserJet 4')
prtdrv=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Control\Print\Printers\%prnt%[Printer Driver]")

; print processor, (i.e. 'Winprint')
prtprc=RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Control\Print\Printers\%prnt%[Print Processor]")

; is it the default printer?
defprt = pGetDefPrtInf(1)

; print driver file, (i.e. 'HPPCL5MS')
hpdrv=StrUpper(RegQueryValue(@REGMACHINE,"System\CurrentControlSet\control\Print\Environments\Windows 4.0\Drivers\%prtdrv%[Driver]"))
hpdrv=StrReplace(hpdrv,".DRV","") 

; delete printer first.
pDelPrinter(prnt)

; Presto, add printer back with new port.
pAddPrinter( "", prnt, newport, prtdrv, prtprc)

; if printer was the default, then we need to set it back.
If defprt == prnt Then pSetDefPrtEx( prnt, hpdrv, newport)

Article ID:   W14435
Filename:   Broadcasting Printer Port Change.txt
File Created: 2001:03:01:15:38:04
Last Updated: 2001:03:01:15:38:04