Transfer Printfile from Printserver directly to Printer

M

Martin Vogler

Hi Guys,
Is there anybody, who can tell me how I can simulate the DOS Command:
Copy filename LPT1
in C++ ?
I have tryed it with the READFILE and WRITEPRINTER commands, but i#ll
get only chunk on the paper.
thanks for any comment
M. Vogler
 
J

Jaap Versteegh

Hi Guys,
Is there anybody, who can tell me how I can simulate the DOS Command:
Copy filename LPT1
in C++ ?
I have tryed it with the READFILE and WRITEPRINTER commands, but i#ll
get only chunk on the paper.
thanks for any comment
M. Vogler

If you want to invoke the DOS shell I think you will need the "system" call.

I don't know about 'simulating' it, but I think that is off topic here
anyway since it involves dos API (if you can speak of that ;) ) calls that
do not have anything to do with C++ itself.

HTH, Jaap
 
R

Rolf Magnus

Martin said:
Hi Guys,
Is there anybody, who can tell me how I can simulate the DOS Command:
Copy filename LPT1
in C++ ?

#include <fstream>

int main()
{
std::ifstream file("filename");
std::eek:fstream lpt("LPT1");
char c;
while (file.get(c) && lpt.put(c));
}

It will probably be more efficient if you don't copy each character on its
own, but instead read/write in blocks.
 
M

Martin Vogler

Rolf said:
Martin Vogler wrote:




#include <fstream>

int main()
{
std::ifstream file("filename");
std::eek:fstream lpt("LPT1");
char c;
while (file.get(c) && lpt.put(c));
}

It will probably be more efficient if you don't copy each character on its
own, but instead read/write in blocks.
Thanks Rolf for the code, but it doesn't work and I don't know why. I
think I'm to silly to code the problem correctly.
I tried it with two files and it worked but with file and printer
nada:-((( Maybe there is another reason, i code on a laptop without a
parallell port.

Greetings Martin
 
M

Martin Vogler

Rolf said:
Martin Vogler wrote:




#include <fstream>

int main()
{
std::ifstream file("filename");
std::eek:fstream lpt("LPT1");
char c;
while (file.get(c) && lpt.put(c));
}

It will probably be more efficient if you don't copy each character on its
own, but instead read/write in blocks.
Rolf Thausend Thanks, now it works pretty good. I've only to tell LPT1
which netprinter I want:
net use LPT1 \\server\printername. In Austria we will say now: "runs
like a bell" :))
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top