Re: Redirecting lpt1 output to an installed printer
- From: "Jim Carlock" <anonymous@localhost>
- Date: Wed, 9 Aug 2006 12:36:42 -0400
"Jerry" <Jerry@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
The application that I am refering to is an old DOS app that prints
to the lpt1 port. Printing to the defauilt printer isn't working. What
I am doing now is to redirect the output using the "net use"
command. I would like to fully automate the operation.
If there's a recognized printer on that port, it shows up in the
Windows Printer applet, right? Or is the printer not listed in the
list of printers when you start the the printers explorer listing.
I found a pretty neat vbScript in the system32 folder of an XP
system dated 8/23/2001, named prnport.vbs. Definitely an
interesting piece of software. The top of the file reads...
'----------------------------------------------------------------------
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' Abstract:
' prnport.vbs - Port script for WMI on Whistler
' used to add, delete and list ports
' also for getting and setting the port configuration
'
' Usage:
' prnport [-adlgt?] [-r port] [-s server] [-u user name] [-w password]
' [-o raw|lpr] [-h host address] [-q queue] [-n number]
' [-me | -md ] [-i SNMP index] [-y community] [-2e | -2d]"
'
' Examples
' prnport -a -s server -r IP_1.2.3.4 -e 1.2.3.4 -o raw -n 9100
' prnport -d -s server -r c:\temp\foo.prn
' prnport -l -s server
' prnport -g -s server -r IP_1.2.3.4
' prnport -t -s server -r IP_1.2.3.4 -me -y public -i 1 -n 9100
'
'----------------------------------------------------------------------
And then all sorts of information about it and the other .vbs scripts
exists on the net. Just searching for its name turns up quite a bit of
detail.
Microsoft provides some information about it here:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prnport.mspx
http://technet2.microsoft.com/windowsserver/en/library/24390518-1C91-40FF-8046-E75B10C27E121033.mspx
Then, PrnAdmin.dll exists on Windows NT4 and Windows 2000
when the appropriate resource kit gets installed. Microsoft provides
some help with that here:
http://support.microsoft.com/?kbid=321025
Converting the vbScript to actual VB code takes little time, and
using ShellExecute to run the items instead of using wscript.run
works for the most part (for running any sort of external executable).
But then going back to what I posted, you can list the names of
all the "VB recognized" printers connected to the system (meaning
if the printer actually shows up in the explorer applet [named "Printers
and Faxes" on Windows XP] ). You failed to identify if the printer
gets recognized by the system, so no one here knows exactly how
the situation over there exists.
A rereading of your initial question brings up some things...
I have an application that outputs to lpt1. I have a vb6 application
that lists all my printers and allows me to select one. I then pass
the selected printer to a batch file that calls "net use lpt1" to redirect
the output. This doesn't work to well. The program does not know
when the batch job is complete, or if it completed successfuly. Is
there a way to redirect the lpt1 output to a windows printer from
within a vb6 application?
I read that as...
2 applications work together. The first application I don't own the
source code for, the second application is my VB6 app. The first
app sends its data to LPT1:. So I need to intercept the LPT1: port,
which I do via a "net use LPT1" command inside a batch file.
So I guess that in your batch file you issue the "Net Use" command,
then start your VB program, then start the program that sends data
sends data to LPT1, whereby the VB App intercepts the data that
comes in over LPT1.
And your looking for a way to get VB to hook up to intercept all
stuff coming out of the LPT1 port and negotiate with the other app
as its occuring?
That seems a little more than I initially garnered. I seem to recall
a mode.com command getting used for some redirection things,
but I could be way off target there. Perhaps not though...
MODE LPT1:=CON:
should stream information to the console, and then a redirection
symbol >> could be used to put it in a file. Just not sure how to
get this done with a VB app right at the moment, but it seems
like it might be worth investigating. In other words run the MODE
statement in the batch file, then run your app like:
C:\PathTo\MyApp.Exe >> file.ext
I await your answer. Ralph might be on the right track. There a
way to redirect the stuff from LPT1 to a file, then read the data
in the file with VB? A timer could check for the presence of the
file and work things from there.
--
Jim Carlock
Post replies to the group.
.
- Follow-Ups:
- References:
- Re: Redirecting lpt1 output to an installed printer
- From: Jim Carlock
- Re: Redirecting lpt1 output to an installed printer
- Prev by Date: Re: How do I change the name of an executable?
- Next by Date: Re: How do I change the name of an executable?
- Previous by thread: Re: Redirecting lpt1 output to an installed printer
- Next by thread: Re: Redirecting lpt1 output to an installed printer
- Index(es):
Relevant Pages
|