DWORD CALLBACK CopyProgressRoutine(
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 param // passed by CopyFileEx
)
{
//if(TotalBytesTransferred*100%TotalFileSize)
{
((CDbfUpdateDlg*)param)->m_ShowProgress.SetRange32(1,100);
((CDbfUpdateDlg*)param)->m_ShowProgress.SetPos(TotalBytesTransferred.QuadPart*100/TotalFileSize.QuadPart);
}
if(pbCancel)return TRUE;
return FALSE;
}
DWORD CopyThreadFunc(LPDWORD param)
{
pbCancel=FALSE;
CopyFileEx(
((CDbfUpdateDlg*)param)->CopyFileName.SFile,
((CDbfUpdateDlg*)param)->CopyFileName.DFile,
CopyProgressRoutine,
param,
&pbCancel,
COPY_FILE_FAIL_IF_EXISTS
);
return 0;
}
//说明 CopyThreadFunc(LPDWORD param)
创建一线程进行文件拷贝
CopyProgressRoutine为CopyFileEx的回调函数
返回true则拷贝停止,可以在其中显示进度