Aaron
Aaron

Reputation: 4480

What is dwLowDateTime and dwHighDateTime

I know they are variables in the FileTime struct, but what is the low-order and high-order part of the file time?

Upvotes: 2

Views: 8075

Answers (2)

Andrew Komiagin
Andrew Komiagin

Reputation: 6556

That is legacy stuff. The point was to have 64-bit value by having couple of 32-bit values. So afterwords you'll end up doing:

FILETIME ft;
// get time here
__int64 fileTime64;
memcpy( &fileTime64, &ft, sizeof( __int64 ) );

Or, as Microsoft wants you to do it:

FILETIME ft;
// get time here
ULARGE_INTEGER ul;
ul.LowPart = ft.dwLowDateTime;
ul.HighPart = ft.dwHighDateTime;
__int64 fileTime64 = ul.QuadPart;

Upvotes: 4

David Heffernan
David Heffernan

Reputation: 613003

Older compilers did not have support for 64 bit types. So the structure splits the 64 bit value into two 32 bit parts. The low part contains the least significant 32 bits. The high part contains the most significant 32 bits.

So if you have the two 32 bit parts, the corresponding 64 bit value is

low + 2^32 * high

The officially santioned way to get a 64 bit value from the two 32 bit parts is via the ULARGE_INTEGER union.

From the FILETIME documentation:

It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should copy the low- and high-order parts of the file time to a ULARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.

Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows.

Upvotes: 8

Related Questions