Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using progressbar to show disk operation.

Posted on 1998-02-18
4
213 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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