From: neilsolent on
> >One further question - is there an inverse function to this:
>
> >void TimetToFileTime(time_t t, LPFILETIME pft)
>
> >.. I need to convert FILETIME back to time_t in another part of the
> >code.
>
> I can't immediately find one to copy, but that example on MSDN is only
> simple maths, so just to the inverse operations.

Here's my working implementation - just to wrap this thread up:

[code]
void FileTimeToTimet(LPFILETIME pft, time_t* t)
{
*t = (((pft->dwHighDateTime - 27111902) << 32) - 3577643008 + pft-
>dwLowDateTime) / 10000000;
}
[/code]
From: neilsolent on
> >.. I need to convert FILETIME back to time_t in another part of the
> >code.
>
> I can't immediately find one to copy, but that example on MSDN is only
> simple maths, so just to the inverse operations.
>
> Dave

Here's my implementation (removed previous post - had overflow error
with larger dates):

[code]

time_t FileTimeToTimet(LPFILETIME pft)
{
ULONGLONG ull = UInt32x32To64((pft->dwHighDateTime - 27111902) * 2,
2147483648) + pft->dwLowDateTime - 3577643008;
return (time_t) (ull / 10000000);
}

[/code]