Solved

accessing printer stream in c++ for windows

Posted on 1997-01-30
1
478 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

743 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

14 Experts available now in Live!

Get 1:1 Help Now