Solved

Using progressbar to show disk operation.

Posted on 1998-02-18
4
210 Views
Last Modified: 2010-04-04
This question has probably been asked before but here it goes.

How do one go about using a progressbar to show disk operation as in the following:

Copying of files, to show how much of the file has been copied,

0
Comment
Question by:delbrad
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Waldek
ID: 1359569
You may use SHFileOperation . It show a progress window. If it is no way tell.
0
 

Author Comment

by:delbrad
ID: 1359570
Thanks for the quick response but that was not what I was looking for, I want to be able to use my own dialog with a progressbar...
0
 
LVL 2

Expert Comment

by:Waldek
ID: 1359571
OK. If You copy using BlockRead You must read by block. If You know number of block You may update progressbar
0
 
LVL 5

Accepted Solution

by:
inter earned 30 total points
ID: 1359572
If you copy file from you application, take this. Otherwise this does not help. Also you may want to enhance this. We worked before so no need to demand more points.

Bye friend, (and bye to all the other friends may this piece of code works!-no no I use it several times dont wory!)

Igor

{
  Copies a file from S to D, and if Pr <> nil updates it
}
procedure CopyFileX(Pr : TProgressBar ;SOffset : LongInt; S, D: String);
var
  Src, Dest : TFileStream;
  Ptr  : pointer;
  red  : longint;
begin
 Ptr:= nil;
 Src:= nil;
 Dest:= nil;
 try
  Src := TFileStream.Create(S, fmOpenRead);
  Src.Seek(SOffset, soFromBeginning);
  Dest:= TFileStream.Create(D, fmCreate or fmOpenWrite);
  if Pr <> nil then
  begin
    Pr.Max := Round(Dest.Size/1024);
    Pr.Position := 0;
  end;
  GetMem(Ptr, 32000);
  while Src.Position <> Src.Size do
  begin
    red := Src.Read(Ptr^, 32000);
    Dest.Write(Ptr^, red);
    if Pr <> nil then
      Pr.StepBy(Round(red/1024));
    Application.ProcessMessages;
  end;
 finally
  if Assigned(Ptr) then FreeMem(Ptr, 32000);
  if Assigned(Src) then Src.Free;
  if Assigned(Dest) then Dest.Free;
 end;
end;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now