windows time

This is a discussion on windows time within the C++ Programming forums, part of the General Programming Boards category; hi, im curious of how to retieve windows created, last accessed and modified times and dates from files on the ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    99

    windows time

    hi, im curious of how to retieve windows created, last accessed and modified times and dates from files on the windows OS. At the mintue i am streaming from my files reading data and so on but i think it would be useful to retrieve the dtes and times for these files as well.
    Ive been having a look around and i think i need something like 'filetimetosystemtime' but im not sure if this is the one? I think they use FILETIME and SYSTEMTIME but im not really familiar with using these funtions, does anyone know any good sites for research on this topic?

    any advice would be appreciated

    thank you

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by pastitprogram View Post
    does anyone know any good sites for research on this topic?

    any advice would be appreciated

    thank you
    msdn.com

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Last edited by cpjust; 10-29-2008 at 06:29 PM. Reason: Added a link to _stat() on MSDN
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    99
    thanks, been browsing the msdn website and seem to have found somthing very usefull! Not totaly sure i fully understand what it is trying to tell me but i think it is definatly of use!


    Code:
    HANDLE hFile;                            // file handle?
    
    FILETIME ftCreate, ftAccess, ftWrite;     // variables for storing dates?
        
    SYSTEMTIME stUTC, stLocal;                 // Not sure
    
    GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))        // I think this is retrieving the times from the file handle hFile
    
     FileTimeToSystemTime(&ftWrite, &stUTC);   //conversion to time?
    
    
    cout << stLocal.wMonth, stLocal.wDay, stLocal.wYear,
            stLocal.wHour, stLocal.wMinute;                                     //printing out the date?
    I think i understand the basic jist of things but im not sure how to get a 'handle' on my file that i am examining and want to retrieve the time and date from? I think will cause me a lot of trouble i think

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You get a handle to the file by calling CreateFile().

    I'm not sure if _fileno() will also return a WIN32 handle, or if it's some other implementation of "handle".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 06:48 PM
  2. The space time continueimnms mm... (rant)
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 06-27-2004, 02:21 PM
  3. Windows Rant followed by installation question
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 06-21-2003, 05:42 PM
  4. FlashWindowEx not declared?
    By Aidman in forum Windows Programming
    Replies: 3
    Last Post: 05-17-2003, 03:58 AM
  5. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 07:51 PM

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