int cancel=false;bool copyok=CopyFileEx(sFromPath,// name of existing filesToPath,// name of new fileMyCopyProgressRoutine,// callback functionprogressBar,// callback parameter&cancel,// cancel statusNULL);// copy options
DWORD CALLBACK MyCopyProgressRoutine( LARGE_INTEGER TotalFileSize, // total file size, in bytes LARGE_INTEGER TotalBytesTransferred, // total number of bytes transferred LARGE_INTEGER StreamSize, // total number of bytes for this stream LARGE_INTEGER StreamBytesTransferred, // total number of bytes transferred for this stream DWORD dwStreamNumber, // the current stream DWORD dwCallbackReason, // reason for callback HANDLE hSourceFile, // handle to the source file HANDLE hDestinationFile, // handle to the destination file LPVOID lpData // passed by CopyFileEx ){QProgressBar *ukaz = (QProgressBar *) lpData;double TBT=TotalBytesTransferred.QuadPart;double TFS=TotalFileSize.QuadPart;double delen=TBT/TFS*100;ukaz->setProgress((int)delen);return PROGRESS_CONTINUE; }
class MyThread : public QThread{public:virtual void run();};void MyThread::run(){int cancel=false;bool copyok=CopyFileEx(...);}