Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Reset Created/Accessed/Modified attribute

  • Please log in to reply
1 reply to this topic
  • Validating
  • 108 posts
  • Last active: Sep 04 2019 06:39 PM
  • Joined: 24 Feb 2006
I have four or so files that I would like to "reset" their Created, Modified, Accessed attributes to a specific date and time once those specific files (in certain directories) are opened/used/accessed etc.
Is there a way to do this with AHK so that it monitors these files and once "finished with" the C/M/A attributes can be applied to. E.g.:

My Documents\Test\file1.txt
My Documents\Test\file2.doc
My Documents\Test\file3.gif
These 3 files were all created on 25 Sep 2004 at 13:00:00

If I were to open any or all of the above listed files today, I want AHK to reset the attributes to 25 Sep 2004 at 13:00:00.
Anyone help me out please?
Thanks very much.

  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
getFileTimes(file,byref ftCreate,byref ftAccess,byref ftModify)
   hFile:=dllCall("CreateFileA", "str",file, "uint",0x80000000, "uint",1|2, "uint",0, "uint",3, "uint",0, "uint",0)
   ifEqual,hFile,-1, return
   dllCall("GetFileTime", "uint",hFile, "int64p",ftCreate, "int64p",ftAccess, "int64p",ftModify)
   dllCall("CloseHandle", "uint",hFile)
   return true

setFileTimes(file, ftCreate, ftAccess, ftModify)
   hFile:=dllCall("CreateFileA", "str",file, "uint",0xC0000000, "uint",1|2, "uint",0, "uint",3, "uint",0, "uint",0)
   ifEqual,hFile,-1, return
   dllCall("SetFileTime", "uint",hFile, "int64p",ftCreate, "int64p",ftAccess, "int64p",ftModify)
   dllCall("CloseHandle", "uint",hFile)
   return true