Hi!
I made an application which copies files, usually large files. I want to show the progress of the copying, but i can't it bring to work. Can someone tell me what i am doing wrong? Now it works very interesting. The % goes to 49% than, back to 0, and then to 40, then again back to 0 and then back 35, and this goes on, untill it copied successfully the file, but i don't understand why get i such a weird percetage. This could be because i calculate the percent variable like i do it later? If i want to calculate percent this way : percent = TotalBytesTransferred*100/TotalFileSize; then i get a compiler error : "error C2676: binary '*' : 'LARGE_INTEGER' does not define this operator or a conversion to a type acceptable to the predefined operator" and this is the reason why i calculate is this way.
Thanks in advance!
kampi
Code:
UINT CopyThread( LPVOID pParam )
{
....
....
....
ret = CopyFileExA( Address.from, Address.to, &MyCopyProgressRoutine, ptr, FALSE,FALSE);
....
....
}
DWORD CALLBACK MyCopyProgressRoutine(
LARGE_INTEGER TotalFileSize, // file size
LARGE_INTEGER TotalBytesTransferred, // bytes transferred
LARGE_INTEGER StreamSize, // bytes in stream
LARGE_INTEGER StreamBytesTransferred, // bytes transferred for stream
DWORD dwStreamNumber, // current stream
DWORD dwCallbackReason, // callback reason
HANDLE hSourceFile, // handle to source file
HANDLE hDestinationFile, // handle to destination file
LPVOID lpData // from CopyFileEx
)
{
TCHAR currentprog[20];
CGetFileListDlg* ptr = (CGetFileListDlg*)lpData;
// do something with pointer, e.g. ptr->m_Progressbar.Pos blahblah
//ptr->m_fileprog.Clear();
//ptr->UpdateWindow();
DWORD percent = (TotalBytesTransferred.HighPart*2^31 + TotalBytesTransferred.LowPart) * 100/(TotalFileSize.HighPart*2^31 + TotalBytesTransferred.LowPart);
wsprintf( currentprog, _T("%d %%"),percent );
ptr->m_fileprog.SetWindowText( currentprog );
return PROGRESS_CONTINUE;
}