Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to find legal 'PrintPort'

Posted on 1997-04-17
6
Medium Priority
?
173 Views
Last Modified: 2010-04-04
Hello, I want to transfer an already preformatted PRN file (all printcodes are already in the file, so no printchars should be added) to the 'currently chosen printer'. The problem I encounter is that only printers that are connected to a (LPT) port are working fine, because I tried it the 'usual' (?) Turbo pascal way, by assiging the printerport (AssignFile(deviceptr, CharP(PrinterPort))

The problem is that when a Printer is not connected via a LPT Port but directly to a Print Queue, this will not work, because you cannot  'open the queue'.

Is there a better way to redirect the preformatted files to the printdevice?

Thanx in advance!
0
Comment
Question by:yogibear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:yogibear
ID: 1335420
Edited text of question
0
 
LVL 1

Accepted Solution

by:
slp earned 200 total points
ID: 1335421
This situation is not going to improve in 32bit Windows environments, because, AFAIK, they won't let you open the port as a file at all.  The only solution that I can think that might work would be to access the printer via the Windows driver and use the Escape() API call with the PASSTHROUGH option, thus sending the contents of the file directly to the printer.  If this sounds like an option, let me know and I can go into more detail.

SLP

0
 

Author Comment

by:yogibear
ID: 1335422
Well... OK, This might work out....,
Please send in some details :)

Thanx up to now!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:slp
ID: 1335423
Delphi provides a Printer object that you can access when you include the "Printers" unit in your uses clause.  This object has a canvas, and the handle to that canvas is the printer's DC.  This handle can be used in the Escape() API call.  So something like the following ought to work (note that I'm doing no special error checking):

uses
  Printers ;

var
  PrnFile : file ;
  Buffer : array [0..1023] of byte ;
  RetVal : integer ;
begin
  AssignFile( PrnFile, 'MYFILE.PRN' ) ;
  Reset( PrnFile ) ;
  repeat
    BlockRead( PrnFile, Buffer, SizeOf( Buffer ), RetVal ) ;
    Escape( Printer.Canvas.Handle, PASSTHROUGH,
      SizeOf( Buffer ), @Buffer, nil ) ;
  until RetVal < SizeOf( Buffer ) ;
  Close( PrnFile ) ;
end ;  

Using Delphi File Streams rather than Pascal untyped files would also be an option, or whatever means you're used to for reading binary files.

HTH

slp


0
 

Author Comment

by:yogibear
ID: 1335424
Seems AllRight, I'll try this!

BTW, In the comment I read I only valued this question 10 points by mistake. I wanted to value this 100pts? Is there a way to give 'slp' the missing 90 points?
0
 
LVL 1

Expert Comment

by:slp
ID: 1335425
Thanks for the offer of the extra points, I'm kind of new here myself, so I don't know who or how to contact someone for "system services" yet, seems like this is mostly automated.

SLP

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question