cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; int Cancel; DWORD CALLBACK ProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, void* lpData) { int Value; Application->ProcessMessages(); if(dwCallbackReason == CALLBACK_CHUNK_FINISHED) Form1->ProgressBar1->Position = ((*(__int64*)&TotalBytesTransferred) * 100) / (*(__int64*)&TotalFileSize); return PROGRESS_CONTINUE; } //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Cancel = false; CopyFileEx("Mi archivo fuente", "Mi archivo destino", ProgressRoutine, NULL, &Cancel, 0); ShowMessage(SysErrorMessage(GetLastError())); } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { Cancel = true; } //---------------------------------------------------------------------------
También en delphi
Saludos.