Article View: borland.public.cppbuilder.nativeapi
Article #9627Re: CopyFileEx - CopyProgressRoutine - devision by zero
From: Tommy
Date: Thu, 24 Jun 2004 22:43
Date: Thu, 24 Jun 2004 22:43
72 lines
3514 bytes
3514 bytes
Hello Bob,
now it works fine. the time which is still need to copy everything looks
great. only the time which the process already runs looks not great. it
seams as the start of this time is 2 hours. but i cant any error here at my
code.
here my code:
AnsiString __fastcall TForm1::FormatTime(SYSTEMTIME *time)
{
String backtime = AnsiString(time->wHour) + AnsiString(":") +
AnsiString(time->wMinute) + AnsiString(":") + AnsiString(time->wSecond);
return backtime;
}
//--------------------------------------------------------------------------
-
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)
{
TForm1 *pForm = (TForm1*) lpData;
if (TotalFileSize.QuadPart > 0)
{
// Aktuellen Dateistatus ermitteln
unsigned __int64 Percent = (((unsigned
__int64)TotalBytesTransferred.QuadPart)*100) / ((unsigned
__int64)TotalFileSize.QuadPart);
pForm->CGauge1->Progress = Percent;
// Aktuellen Status aller Dateien ermitteln
pForm->tmp = (unsigned __int64)TotalBytesTransferred.QuadPart;
Percent = ((unsigned
__int64)((pForm->already_copied+pForm->tmp)*100))/(unsigned
__int64)(pForm->size);
pForm->CGauge2->Progress = Percent;
}
// restzeitberechnung
now.i64 = 0;
remaining.i64 = 0;
elapsed.i64 = 0;
unsigned __int64 BytesRemaining = pForm->size - pForm->already_copied;
SYSTEMTIME SystemTime;
GetLocalTime(&SystemTime);
SystemTimeToFileTime(&SystemTime, &now.ft);
elapsed.i64 = now.i64 - StartTime.i64;
FileTimeToSystemTime(&elapsed.ft, &SystemTime);
pForm->LBisherdauer->Caption = pForm->FormatTime(&SystemTime);
remaining.i64 = ((BytesRemaining * (elapsed.i64/10000U)) /
(pForm->already_copied+1))*10000U;
FileTimeToSystemTime(&remaining.ft, &SystemTime);
pForm->LRestdauer->Caption = pForm->FormatTime(&SystemTime);
// Updaten
pForm->Update();
Application->ProcessMessages();
return PROGRESS_CONTINUE;
}
//--------------------------------------------------------------------------
-
tommy
Technical Details
Message-ID:
<40db5933@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40ce2e93@newsgroups.borland.com> <crtsc0pp05ki34cqsvkgsj721eei6g7obh@4ax.com> <40cef067$1@newsgroups.borland.com> <8hauc01e3dsrlu787m5s8jo10rpu0k3duq@4ax.com> <40d3589b@newsgroups.borland.com> <2bj7d0dc8b89se5ibtdm7nntbvsrga2lrt@4ax.com> <40d8b34c$1@newsgroups.borland.com> <qfojd0dhd57q45be09tt1u8klea9fglliq@4ax.com> <40d9f233@newsgroups.borland.com> <uavjd0lvdhuhdvosclehlarvvfagceecmn@4ax.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: "Tommy" <tommyw@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40ce2e93@newsgroups.borland.com> <crtsc0pp05ki34cqsvkgsj721eei6g7obh@4ax.com> <40cef067$1@newsgroups.borland.com> <8hauc01e3dsrlu787m5s8jo10rpu0k3duq@4ax.com> <40d3589b@newsgroups.borland.com> <2bj7d0dc8b89se5ibtdm7nntbvsrga2lrt@4ax.com> <40d8b34c$1@newsgroups.borland.com> <qfojd0dhd57q45be09tt1u8klea9fglliq@4ax.com> <40d9f233@newsgroups.borland.com> <uavjd0lvdhuhdvosclehlarvvfagceecmn@4ax.com> Subject: Re: CopyFileEx - CopyProgressRoutine - devision by zero Date: Fri, 25 Jun 2004 00:43:54 +0200 Lines: 74 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 217.88.146.164 Message-ID: <40db5933@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1088117043 217.88.146.164 (24 Jun 2004 15:44:03 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail