Article View: borland.public.cppbuilder.nativeapi
Article #9769Re: CopyFileEx - CopyProgressRoutine - devision by zero
From: Bob Gonder
Date: Tue, 15 Jun 2004 04:17
Date: Tue, 15 Jun 2004 04:17
29 lines
2277 bytes
2277 bytes
Tommy wrote:
>DWORD WINAPI MyCopyProgressRoutine(LARGE_INTEGER TotalFileSize,LARGE_INTEGER
>TotalBytesTransferred,LARGE_INTEGER StreamSize,LARGE_INTEGER
>StreamBytesTransferred,DWORD dwStreamNumber,DWORD dwCallbackReason,HANDLE
>hSourceFile,HANDLE hDestinationFile,LPVOID lpData)
>{
> unsigned __int64 Percent = (((unsigned
>__int64)TotalBytesTransferred.QuadPart)*100) / ((unsigned
>__int64)TotalFileSize.QuadPart);
Are you sure you aren't copying any zero-size files?
> pForm->tmp = (unsigned __int64)TotalBytesTransferred.QuadPart;
> Percent = ((unsigned
>__int64)((pForm->already_copied+pForm->tmp)*100))/(unsigned
>__int64)(pForm->size);
You don't show where pForm->size is set or calculated.
But the problem if most likely the first one (zero size files)
>In my copyprogressroutine, i have some source to calcuale how man percent
>have already copied of that file and of the hole process. As i work with big
>files i use unsigned __int64. but when i run my appliaction i always get
>after a short time the message "devision by zero" and the application stops.
>when i comment the calculation of the percent, the application run fine.
>what is wrong with my calcution. what to change that is calculate the copied
>bytes of the file and of the hole process?
Technical Details
Message-ID:
<crtsc0pp05ki34cqsvkgsj721eei6g7obh@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40ce2e93@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,9a3709a4832c0e51 X-Google-Attributes: gid10cc67,public From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: CopyFileEx - CopyProgressRoutine - devision by zero Date: Mon, 14 Jun 2004 21:17:25 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <crtsc0pp05ki34cqsvkgsj721eei6g7obh@4ax.com> References: <40ce2e93@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 65.173.66.53 X-Trace: newsgroups.borland.com 1087273043 65.173.66.53 (14 Jun 2004 21:17:23 -0700) Lines: 31 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail