I can't seem to get a reliable timestamp using winapi functions. For example:
int main(int argc, char *argv[])
{
HANDLE file;
BY_HANDLE_FILE_INFORMATION finfo;
SYSTEMTIME systime;
file = CreateFile("test.txt",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
GetFileInformationByHandle(file,&finfo);
FileTimeToSystemTime(&finfo.ftLastWriteTime, &systime);
printf(" %s %02d:%02d:%02d %d/%d/%d\n", "test.txt", systime.wHour,systime.wMinute,systime.wSecond,systime.wDay,systime.wMonth,systime.wYear);
}
gives non-sense on all my files like:
test.txt 00:03:30 33/5/3
wDay seems to have values outside of range 1-31 and the times and dates are totally wrong. All other values in the BY_HANDLE_FILE_INFORMATION like name and size are correct, and in I full code I check for errors from all functions, but they all return passed. Anyone know what I am doing wrong?