Q:

How to get last modified date of file

I'm trying to get the last modified date of a file and this turns out to be more complicated than I thought. My first attempt was this:
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
GetFileTime(hFile, &creationTime, &lastAccessTime, &lastWriteTime);     
FileTimeToSystemTime(&lastWriteTime, &t);

printf("TEST: %d %d %d\n", t.wHour, t.wMinute, t.wSecond);

I've tested this with a file on my HD whose last modified date is reported by Explorer as Friday 21st March, 1997, 14:34:58. Now with the code above I got the same date except that the time is reported as 13:34:58, i.e. one hour off. So I thought this is probably related to missing timezone/DST adjustments so I added a call to FileTimeToLocalTime(), i.e. like this:
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
GetFileTime(hFile, &creationTime, &lastAccessTime, &lastWriteTime);
FileTimeToLocalFileTime(&lastWriteTime, &ft);               
FileTimeToSystemTime(&ft, &t);

But now the time is reported as 15:34:58, i.e. still one hour off but now in the opposite direction. So I still don't get the 14:34:58 as reported by Explorer. 
That's why I'd like to ask how I can get the last modified date as reported by Explorer. Anyone?

A:

The blog "Why do Explorer and the command prompt interpret file times differently?" address the reason for why you get different last modified time of a file from Windows API and from Explorer: "Daylight Saving Time".
To account for daylight saving time when converting a file time to a local time, use the following sequence of functions in place of using FileTimeToLocalFileTime:

FileTimeToSystemTime 
SystemTimeToTzSpecificLocalTime 
SystemTimeToFileTime.

