Link to home
Start Free TrialLog in
Avatar of VCGuru
VCGuru

asked on

Printing

Hi,
1. How to give a print command using ANSI C++?
2. How do I identify whether a printer is connected or not?
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In DOS, "LPT1:", which is usually your parallel port, can be treated like a file.
So you can open the printer port by use file functions like open, fopen, or ofstream.
Then you can write to it just as you would to a file.
To open the port just use "LPT1" as the file name. If your printer is connected to parallel port 2 or 3, then use "LPT2:" or "LPT3:".

What is your OS, and what is your compiler?
Actually, I should have left out the colon.

Example:
system("copy test.cpp LPT1");


Continue....
If you want to print to a network printer, you can use the "Net Use" command.

Example:
//Remove any previous connections to LPT3
system("net use LPT3: /del");

//Connect to printer called dale on 'scsetbprt01.axter.com' server to port LPT3
system("NET USE LPT3: \\\\scsetbprt01.scsnet.csc.com\\dale");
Dear VCGuru

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "Axter"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Avatar of Mindphaser
Mindphaser

Force accepted

** Mindphaser - Community Support Moderator **