-
Hex Time to FileTime
I am trying to convert a hex date/time value to a date format. I already know how to convert it to a readable format but I can't get it to the filetime format.
Code:
The hex value I got is: 0x60 0x16 0x59 0x8F 0x7C 0xF0 0xC6 0x01
I reverse the values (little endian) and put them into two separate char values:
Code:
szHigh[] = {0x01,0xC6,0xF0,0x7C};
szLow[] = {0x8F,0x59,0x16,0x60};
Now I need the put both of the sz values into the high and low DWORD locations of the FileTime struct:
Code:
LastWritten.dwHighDateTime = atol(szHigh);
LastWritten.dwLowDateTime = atol(szLow);
The above code always returns 0 for both values.
What am I doing wrong and is there a better way to convert a date stamp to the FileTime format?
-
I solved it already.
I made a mistake by reversing the little endian stuff.
Solution:
Code:
szHigh[] = {0x7C, 0xF0, 0xC6, 0x01};
szLow[] = {0x60, 0x16, 0x59, 0x8F};
LastWritten.dwHighDateTime = *(unsigned long *)szHigh;
LastWritten.dwLowDateTime = *(unsigned long *)szLow;