Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FILETIME to TDateTime

308 views
Skip to first unread message

Tolga Balci

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to
How do I read/convert the Windows FILETIME struct into a TDateTime?

Bruce Rosner

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to

Tolga Balci wrote in message <7a21p9$qk...@forums.borland.com>...

>How do I read/convert the Windows FILETIME struct into a TDateTime?


Try something like:

FILETIME ft;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);

TDateTime dt = TDateTime(st.wYear, st.wMonth, st.wDay)
+ TDateTime(st.wHour, st.wMinute, st.wSecond,
st.wMilliseconds);

// Note: FileTimetoSystemTime is a standard NT API function.


Bruce Rosner

unread,
Feb 12, 1999, 3:00:00 AM2/12/99
to

Tolga Balci wrote in message <7a21p9$qk...@forums.borland.com>...
>How do I read/convert the Windows FILETIME struct into a TDateTime?
>
Try something like this:

FILETIME ft;
SYSTEMTIME st;

FileTimeToSystemTime(&ft, &st);

TDateTime dt = TDateTime(st.wYear, st.wMonth, st.wSecond)


+ TDateTime(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);

// Note: FileTimeToSystemTime is a standard Win32 API function.


Tolga Balci

unread,
Feb 14, 1999, 3:00:00 AM2/14/99
to
Cool... that will do it folks !!

*thanx* Bruce !

-Tolga
Systems Administrator
Post Time Research
-------------------------------

PS: Is it only me or does everybody else think that it is odd ( more like stupit or
retarded ) for VCL's TDateTime to support direct conversion from and to the old Dos
filedate format but not to the Windows FILETIME.. format????

Bruce Rosner <bro...@pacbell.net> wrote in message
news:7a2ijr$qk...@forums.borland.com...

Tolga Balci

unread,
Feb 16, 1999, 3:00:00 AM2/16/99
to
I think this is the best way to get a file date/time as reported by WinAPI functions
converted to a TDateTime:

TDateTime FileTimeToDateTime( FILETIME *FileTime )
{
FILETIME LocalFileTime;
SYSTEMTIME SystemTime;

FileTimeToLocalFileTime( FileTime, &LocalFileTime );
FileTimeToSystemTime( &LocalFileTime, &SystemTime );

return SystemTimeToDateTime( SystemTime );
}

Tolga Balci <admini...@itsposttime.com> wrote in message
news:7a21p9$qk...@forums.borland.com...

0 new messages