利用CopyFileEx函数显示拷贝进度条
DWORD CALLBACK CopyProgress(
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
)
{
Form1->ProgressBar1->Position = TotalBytesTransferred.LowPart
/ TotalFileSize.LowPart * 100;
return PROGRESS_CONTINUE;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int nCancel = false;
CopyFileEx("C:\\ccrun\\123.exe", "C:\\ccrun\\234.exe",
(LPPROGRESS_ROUTINE)CopyProgress, NULL,
&nCancel, COPY_FILE_FAIL_IF_EXISTS);
}