TFileCopy



 

TFileCopy is a component designed for very fast filecopy without 
external, coarse calls involving the O.S.
Furthermore it sends the percentages of read and written blocks
to the calling form (by the API SendMessage).
If two TProgressBar (Delphi 3.0) components (or any other component like that) are used 
the progress can be visually shown during the copy.
The method handling the message must use the WM_FILECOPY predefined constant 
declared inside FileCopy.pas.
Every time the message is received, wParam contains the read percentage 
and lParam the written percentage.
For reading and writing low-level calls to FileRead and FileWrite have been used
to avoid the error generated by the reset standard procedure on opening
read-only files like from a CD-ROM. 

  Properties : Name ShowOverwrite SourceFile Tag TargetFile 

* Name . . . 
* ShowOverwrite True allows a dialog calling if you want overwrite an
  existing file, otherwise TFileCopy copy overwrites it without asking
* SourceFile is the full path-name of the source file
* Tag ...
* TargetFile is the full path-name of the target file
SourceFile and TargetFile can be different. 

  Method : ExecCopy 

* ExecCopy just starts the copy. 

This is an example of the message handling method on the calling form : 

procedure TForm1.WMFileCopy(var Msg : TMessage);
begin
   with Msg do
   begin
      ProgressFrom.position := wParam; 
      ProgressTo.position   := lParam;
      ProgressFrom.repaint;
      ProgressTo.repaint;
   end;
end; 

ProgressFrom and ProgressTo are two TProgressBar components. 

If you don't declare any method handling the message, TFileCopy works
all the same and much faster.
 

*** First problem 

FileCopy.DCR is compiled with Delphi 1.0 so it doesn't work with the following
versions, but you can easily upgrade it with any resource tool kit just
1) renaming it from .DCR to .RES
2) upgrading to 32 bit
3) renaming it again from .RES to .DCR 

*** Second problem 

The constant wm_filecopy is coded as := wm_user + 7777.
It's possible that this is a value already in use in your application and
this will cause unforseeable behaviours ...
Sorry, but the value in FileCopy.pas must be changed or 
any method to handle the message must not be declared.
I've tried to present it like an editable property but in the declaration
part of the calling form, any attribute values of an owned component
isn't visible and that causes the message :
  Error : unknown identifier
after the reserved word 'message' . 

 

 back to download