Ver Mensaje Individual
  #2  
Antiguo 12-08-2007
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Reputación: 20
cHackAll Va por buen camino
El uso de un ProgressBar con el tamaño total de un archivo funciona siempre y cuando éste no sobrepase los 2147483647 bytes, (~2 Gb), dejo mis correcciónes aconsejando usar un hilo para no "perjudicar" al hilo principal:

Código Delphi [-]
...

implementation

{$R *.dfm}

var Cancel: LongBool;

function ProgressRoutine(TotalFileSize, TotalBytesTransferred, StreamSize, StreamBytesTransferred: Int64; dwStreamNumber, dwCallbackReason, hSourceFile, hDestinationFile: Cardinal; lpData: Pointer): Cardinal; stdcall;
var Value: Cardinal;
begin
 Application.ProcessMessages;
 case dwCallbackReason of
  CALLBACK_CHUNK_FINISHED: Form1.ProgressBar1.Position := (TotalBytesTransferred * 100) div TotalFileSize;
//  CALLBACK_STREAM_SWITCH: Form1.ProgressBar1.Max := 100;
 end;
 Result := PROGRESS_CONTINUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 CopyFileEx('F:\DVD\Prince of Persia\Prince of Persia (The two thrones).mdf', 'e:\Dummy.mdf', @ProgressRoutine, nil, @Cancel, 0);
 ShowMessage(SysErrorMessage(GetLastError));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 Cancel := True;
end;

end.
Responder Con Cita