Solved

accessing printer stream in c++ for windows

Posted on 1997-01-30
1
483 Views
Last Modified: 2006-11-17
I've got what's probably a really easy question,
but I can't seem to find an answer in several different
books...can someone tell me how to send a stream to the
printer in borland c++ for windows?
 I've tried:
#define printer "LPT1"
  and
#define printer "PRN"
 even
#define printer "PRN:LPT1"
 then
ofstream outf;
outf.open(printer);  c++ seems to recognize PRN and LPT1 as valid
outf <<...           constants--no errors on run
                      but output is sent to screen(window).
the text says that stdio.h has a stream called stdprn
and i've tried to use
 fprintf(stdprn,"this is a test");
just to try that, and it goes to screen also.
The least capability I need is to be able to create a file then
print hard copy from within the program...I would like to be able
to send individual lines to printer for headers or summary that I
don't want in the actual file.
  Pardon me if I've missed something obvious.....
BTW this is windows 3.11 and borland c++4.52 (I also have turboc++3.1)

                thanks in advance
                    kevin
0
Comment
Question by:kellis
1 Comment
 

Accepted Solution

by:
cstaley earned 50 total points
ID: 1161865
You don't say whether you are using an EasyWin application or not.  I assume you are.  I'm not certain, but I don't believe there is any easy way to do printer output.  The only way I've been able to do printer output under Windows is to use TPrinter and its associated classes.  The problem is that the printer is a spooled device, and Windows does *not* like you to take direct control of it.  Instead, you are expected to interact with the print manager.  I would have expected Borland to supply you with a "fake IO stream" under EasyWin that would take care of interacting with the print manager, but apparently they don't.

Clint


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
why "." vs "->" 23 119
Exception thrown at 0x00007FFD5BC81F28 7 38
Safe conversion? 4 58
What is sub-make ? 2 39
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

895 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

12 Experts available now in Live!

Get 1:1 Help Now