Board index » delphi » HELP!!! WINEXEC and DOS COPY command - DELPHI 1.0

HELP!!! WINEXEC and DOS COPY command - DELPHI 1.0

I am creating a windows application based on an old DOS program.  The
app calls a dos program that creates a text file FILE.RRR.  To print
this text file we would copy the setup commands for the laser printers
and the file to LPT1 ie. "COPY f:\laser\setup05p.lsr+FILE.RRR LPT1"
Simple and it works.
My problem is that in Delphi, WINEXEC works fine for calling the dos
program and making the FILE.RRR but when I go to print using the PChar
equivalent of WINEXEC('COPY f:\laser\setup05p.lsr+FILE.RRR LPT1') I get
a file not found error (2).  

WHY?  

Winexec doesn't seem to be able to run internal DOS commands.  I get the
same error when I substitute 'type'.  If this is not the case please
tell me what I am doing wrong or another way to print this text file.

Any Help would be appreciated.

Larry Rice
Market Trends - A Research Company

 

Re:HELP!!! WINEXEC and DOS COPY command - DELPHI 1.0


Quote
lcr...@ix.netcom.com wrote:
>I am creating a windows application based on an old DOS program.  The
>app calls a dos program that creates a text file FILE.RRR.  To print
>this text file we would copy the setup commands for the laser printers
>and the file to LPT1 ie. "COPY f:\laser\setup05p.lsr+FILE.RRR LPT1"
>Simple and it works.
>My problem is that in Delphi, WINEXEC works fine for calling the dos
>program and making the FILE.RRR but when I go to print using the PChar
>equivalent of WINEXEC('COPY f:\laser\setup05p.lsr+FILE.RRR LPT1') I get
>a file not found error (2).  

>WHY?  

>Winexec doesn't seem to be able to run internal DOS commands.  I get the
>same error when I substitute 'type'.  If this is not the case please
>tell me what I am doing wrong or another way to print this text file.

COMMAND COPY F:\....

Also there is a switch to tell command to terminate immediately afterwards.
Check the COMMAND /? first.
--
Stefan.Hoffmeis...@UNI-Passau.DE
http://kakadu.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany

Re:HELP!!! WINEXEC and DOS COPY command - DELPHI 1.0


Quote
Stefan Hoffmeister wrote:
> >and the file to LPT1 ie. "COPY f:\laser\setup05p.lsr+FILE.RRR LPT1"
> >Simple and it works.
> >My problem is that in Delphi, WINEXEC works fine for calling the dos
> >program and making the FILE.RRR but when I go to print using the  

I had a similar problem with printing a report my program output..  All
I did was use shellexecute instead..  I have included a snippit that
might help your cause...

  getmem(path,length(top_form.mydir('report.txt'))+1);
  strpcopy(path,top_form.mydir('report.txt'));
  shellexecute(0,'print',path,'','',SW_HIDE);

Regards,

Jeff

Re:HELP!!! WINEXEC and DOS COPY command - DELPHI 1.0


Quote
In <332F4F0B.5...@ix.netcom.com>, lcr...@ix.netcom.com writes:
>My problem is that in Delphi, WINEXEC works fine for calling the dos
>program and making the FILE.RRR but when I go to print using the PChar
>equivalent of WINEXEC('COPY f:\laser\setup05p.lsr+FILE.RRR LPT1') I get
>a file not found error (2).  

>WHY?  

You have to run COMMAND.COM (or rather the shell that COMSPEC points to.)
If you just need a straight copy program you could try running XCOPY which
is an external program. Check your DOS manual how to run an internal command
with COMMAND.COM. I can't recal the syntax at the moment.

Rolf Grunsky

Other Threads