home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0148_Re: System Commands.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-30  |  868 b   |  33 lines

  1.  
  2. {
  3. > How do you get Delphi to execute system commands such as copy and rename?
  4. > I tried using WINEXEC, but it doesn't recognize copy. It does handle the
  5. > commands if I put them in a .bat file. I need this application to work
  6. > across all three platforms (95, NT, 3.1). Do I have to do this with bat
  7. > files? (yuck)
  8. >
  9. > Joe Silva
  10. >
  11. > p.s. Please reply via mail too. Thanks.
  12.  
  13. Try something like the following:
  14. }
  15.  
  16.   procedure CopyDos (FileIn, FileOut: PChar);
  17.   var
  18.     CommandLine: array[0..$FF] of Char;
  19.   begin
  20.   StrCopy (CommandLine, GetEnvVar ('COMSPEC'));
  21.   StrCat  (CommandLine, ' /c copy ');
  22.   StrCat  (CommandLine, FileIn);
  23.   StrCat  (CommandLine, ' ');
  24.   StrCat  (CommandLine, FileOut);
  25.   WinExec (CommandLine, sw_Hide);
  26.   end;
  27.  
  28. COMSPEC is necessary in case you are running DR DOS.
  29.  
  30. Best regards,
  31. Michael Vincze
  32. vincze@ti.com
  33.