// Get current system time and convert to file time
SYSTEMTIME st;
FILETIME ft;
GetSystemTime( &st );
SystemTimeToFileTime( &st, &ft );
// convert to FILETIME to ULARGE_INTEGER
// don't have code in front of me, so guessing what names of variables. But
you get the idea
ULARGE_INTEGER uli;
uli.High = ft.dwHighPart;
uli.Low = ft.dwLowPart;
// HERE'S WHERE I NEED HELP
uli.High -= 1; // from my dinking around, I found this subtracts about 7
minutes
// Convert back to FILETIME
ft.dwHighPart = ft.dwHighPart;
ft.dwLowPart = ft.dwLowPart;
// Search directory for files greater than ft
...
Anyone know how to subtract minutes from the FILETIME structure?
TIA
This works:
SYSTEMTIME st;
FILETIME ft;
GetSystemTime (&st);
SystemTimeToFileTime (&st, &ft);
ULARGE_INTEGER uli;
uli.HighPart = ft.dwHighDateTime;
uli.LowPart = ft.dwLowDateTime;
// the number of 100-nanosecond intervals in x seconds is
// x * 10^7 . To set the FILETIME struct back 10 min you must subtract
// 10*60*10^7 = 6 * 10^9.
uli.QuadPart -= 6000000000;
// Convert back to SYSTEMTIME
ft.dwHighDateTime = uli.HighPart;
ft.dwLowDateTime = uli.LowPart;
FileTimeToSystemTime (&ft, &st);
Robert S.
From MSDN --
Visual Studio 6.0 Documentation
Visual C++ Documentation
Reference
MFC Library and Templates
MFC Library
Class Library Reference
Structures, Styles, Callbacks, and Message Maps
Structures Used by MFC
FILETIME Structure
"The FILETIME structure is a 64-bit value representing the number of
100-nanosecond intervals since January 1, 1601."
1 minute is 60,000,000,000 nanoseconds.
So, there are 600,000,000 100-nanosecond "ticks" per minute.
Now you can do something like this:
const ULONGLONG minutesPerTick 600000000;
// Get current system time and convert to file time
SYSTEMTIME st;
FILETIME ft;
GetSystemTime( &st );
SystemTimeToFileTime( &st, &ft );
// convert to FILETIME to ULARGE_INTEGER
ULARGE_INTEGER uli;
uli.High = ft.dwHighPart;
uli.Low = ft.dwLowPart;
uli.QuadPart -= numMinutes * minutesPerTick;
// Convert back to FILETIME
ft.dwHighPart = ft.dwHighPart;
ft.dwLowPart = ft.dwLowPart;
Good luck,
-Bret
--
- Bret Wood
- Grass Valley Group / Thomson Multimedia Broadcast Solutions
- bret...@grassvalleygroup.com
> I'm trying to make a program that searches a directory for files added
> after a certain time (ie. within last ten minutes, within last hour,
> etc). MSDN recommends converting FILETIME structures into
> ULARGE_INTEGER structures and then doing 64-bit arithmetic to get the
> desired time. I have not the slightest clue on how to do this. My
> psuedo-code so far looks like this:
>
> // convert to FILETIME to ULARGE_INTEGER
> // don't have code in front of me, so guessing what names of
> variables. But you get the idea
You can get much cleaner code if you use __int64 data type.
Lets make a pointer so the FILETIME struct will be manipulated directly;
__int64 *i = (__int64 *)&ft;
// Now, lets substract five minutes. In nanoseconds one minute would be
__int64 one_minute = (__int64)1e7 * 60; // 60 seconds per minute
*i -= (__int64) 5 * one_minute;
Done!
--
Matti Vuori, <http://sivut.koti.soon.fi/mvuori/index-e.htm>
"Christopher Jackson" <chrisjac...@hotmail.com> wrote in message
news:5a3Y8.501155$352.83400@sccrnsc02...