Hex Time to FileTime

This is a discussion on Hex Time to FileTime within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to convert a hex date/time value to a date format. I already know how to convert it ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    8

    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?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    8
    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;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 09:11 AM
  2. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 08:51 PM
  3. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 11:42 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21