-
November 13th, 2001, 07:56 AM
#1
filetime systemtime and duration
Hello,
I need the day-duration from a file. How long exists the file in days. I get the filetime I can convert it into a systemtime. But I need the duration in days. I don't like to calculate it alone. Now my question. Does any function exist how I can resolve this problem?
-
November 13th, 2001, 08:13 AM
#2
Re: filetime systemtime and duration
Hello,
If you have the the file time as either a SYSTEMTIME or a FILETIME you can use the following code
CTimeSpan ts = CTime::GetCurrentTime() - file_time;
int days=ts.GetDays() ;
Regards
Tony
-
November 13th, 2001, 09:13 AM
#3
Re: filetime systemtime and duration
Thanks a lot.
If you know another class as the CTimeSpan it would be helpfully. Because I can't use MFC. Exist a WIN API function?
-
November 13th, 2001, 09:46 AM
#4
Re: filetime systemtime and duration
Hello
OK, try this. You need to start with a FILETIME.
SYSTEMTIME systime ;
FILETIME now ;
GetSystemTime(&systime) ;
SystemTimeToFileTime(&systime, &now) ;
LONGLONG interval=((LARGE_INTEGER *)&now)->QuadPart - ((LARGE_INTEGER *)&file_time)->QuadPart;
interval/=10000000 ; // file time is 100-nanosecond intervals
int days=(int)(interval/(24*3600)) ;
Regards
Tony
-
November 13th, 2001, 10:03 AM
#5
Re: filetime systemtime and duration
#include "stats.h"
// if you have the 2 FILETIMES we can do
__int64 iFile = INT64_FROM_FILETIME(file);
__int64 iToday = INT64_FROM_FILETIME(today);
__int64 iDiff = iToday - iFile;
// That tells us how many times 100 nanosecs there are
long lDays = iDiff / 864000000000; //100 nanosecs in a day
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|