Connecting Tech Pros Worldwide Forums | Help | Site Map

Transfer Printfile from Printserver directly to Printer

Martin Vogler
Guest
 
Posts: n/a
#1: Jul 23 '05
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


Jaap Versteegh
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Transfer Printfile from Printserver directly to Printer


> Hi Guys,[color=blue]
> 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[/color]

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

Rolf Magnus
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Transfer Printfile from Printserver directly to Printer


Martin Vogler wrote:
[color=blue]
> Hi Guys,
> Is there anybody, who can tell me how I can simulate the DOS Command:
> Copy filename LPT1
> in C++ ?[/color]

#include <fstream>

int main()
{
std::ifstream file("filename");
std::ofstream 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.

Martin Vogler
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Transfer Printfile from Printserver directly to Printer




Rolf Magnus schrieb:[color=blue]
> Martin Vogler wrote:
>
>[color=green]
>>Hi Guys,
>>Is there anybody, who can tell me how I can simulate the DOS Command:
>>Copy filename LPT1
>>in C++ ?[/color]
>
>
> #include <fstream>
>
> int main()
> {
> std::ifstream file("filename");
> std::ofstream 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.
>[/color]
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


Martin Vogler
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Transfer Printfile from Printserver directly to Printer




Rolf Magnus schrieb:[color=blue]
> Martin Vogler wrote:
>
>[color=green]
>>Hi Guys,
>>Is there anybody, who can tell me how I can simulate the DOS Command:
>>Copy filename LPT1
>>in C++ ?[/color]
>
>
> #include <fstream>
>
> int main()
> {
> std::ifstream file("filename");
> std::ofstream 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.
>[/color]
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

Closed Thread