Board index » delphi » Copying files with progress bar?

Copying files with progress bar?

Gerhard Hofmann <gerhard.hofm...@nospam.planat.de> wrote in article
<34536bb3.5621...@news.vossnet.de>...

Quote
> How can I copy files and show the progress in a progress bar?
> -----------------------------------------
> Real address is gerhard.hofm...@planat.de
> Delete the nospam
> Please copy all answers to my email address

Just increment your progress bar each time you do a BlockRead or BlockWrite
(or both with 50% to each one).

--
Regards

Rafael Ribas Aguil (Rio de Janeiro - Brazil)
e-mail: rri...@unisys.com.br

 

Re:Copying files with progress bar?


Rafael Ribas a crit dans le message <01bce33a$067b8d60$6403dcc8@rra>...

Quote
>Gerhard Hofmann <gerhard.hofm...@nospam.planat.de> wrote in article
><34536bb3.5621...@news.vossnet.de>...
>> How can I copy files and show the progress in a progress bar?

You can use the WinAPI and add ShlObj, ShellAPI in "uses"

(* just for remember
type TShFileOpStructA = record
            Wnd : HWnd;
            wFunc : UINT;
            pFrom : PAnsiChar;
            pTo   : PAnsiChar;
            fFlags : FILEOP_FLAGS;
            fAnyOperationsAborted : Bool;
            hNameMappings : Pointer;
            lpszProgressTitle : PAnsiChar;
            end;       *)

var F : TShFileOpStruct;
begin
F.Wnd := Handle;
F.wFunc := FO_COPY;
F.fFlags := FOF_ALLOWUNDO or FOF_SIMPLEPROGRESS;
// files I want to copy on A: (for example)
F.pFrom := 'file1.txt'#0'file2.exe'#0'file3.ini'#0;
F.pTo   := 'A:\';
if shFileOperation(F) <> 0
then ShowMessage('Copy failed !');
end;

Jean-Paul Passama from France
***********************************************
http://perso.wanadoo.fr/passama
***********************************************

Other Threads