Solved

How to find legal 'PrintPort'

Posted on 1997-04-17
6
168 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
  • 3
  • 3
6 Comments
 

Author Comment

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

Accepted Solution

by:
slp earned 100 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 330
Connection between libmysql.dll and MySQL Versions 7 97
Downloading email attachments 2 72
Tvertscrollbox like a whatsapp layout 5 26
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now