Posts: 863
Threads: 197
Joined: Apr 2005
Posts: 12,140
Threads: 142
Joined: Dec 2002
str sFile="$desktop$\test.txt"
dll kernel32 #CreateFile $lpFileName dwDesiredAccess dwShareMode SECURITY_ATTRIBUTES*lpSecurityAttributes dwCreationDisposition dwFlagsAndAttributes hTemplateFile
dll kernel32 #SetFileTime hFile FILETIME*lpCreationTime FILETIME*lpLastAccessTime FILETIME*lpLastWriteTime
def FILE_WRITE_ATTRIBUTES (0x100)
def OPEN_EXISTING 3
int hfile=CreateFile(_s.expandpath(sFile) FILE_WRITE_ATTRIBUTES 0 0 OPEN_EXISTING 0 0)
if(hfile=-1) end _s.dllerror()
DATE d.getclock
FILETIME ft ftutc
d.tofiletime(ft)
LocalFileTimeToFileTime &ft &ftutc
SetFileTime hfile 0 0 &ftutc
CloseHandle hfile
Posts: 863
Threads: 197
Joined: Apr 2005
Thanks.
Happy New Year...
Posts: 12,140
Threads: 142
Joined: Dec 2002
Function SetFileTimes
;/
function $sFile DATE'tMod [DATE'tCreat] [DATE'tAccess] [utc]
;Sets file times.
;Use 0 for times that should not be changed.
;If utc is nonzero, times are interpreted as UTC times. Default - local times.
;EXAMPLE
;;set file modified time to current time
;DATE d.getclock ;;get current local time
;SetFileTimes "$desktop$\test.txt" d
dll kernel32 #CreateFile $lpFileName dwDesiredAccess dwShareMode SECURITY_ATTRIBUTES*lpSecurityAttributes dwCreationDisposition dwFlagsAndAttributes hTemplateFile
dll kernel32 #SetFileTime hFile FILETIME*lpCreationTime FILETIME*lpLastAccessTime FILETIME*lpLastWriteTime
def FILE_WRITE_ATTRIBUTES (0x100)
def OPEN_EXISTING 3
int hfile=CreateFile(_s.expandpath(sFile) FILE_WRITE_ATTRIBUTES 0 0 OPEN_EXISTING 0 0)
if(hfile=-1) end _s.dllerror()
FILETIME ft ftm ftc fta; FILETIME* pftm pftc pfta
if(tMod) pftm=&ftm; tMod.tofiletime(ft); if(utc) ftm=ft; else LocalFileTimeToFileTime &ft &ftm
if(tCreat) pftc=&ftc; tCreat.tofiletime(ft); if(utc) ftc=ft; else LocalFileTimeToFileTime &ft &ftc
if(tAccess) pfta=&fta; tAccess.tofiletime(ft); if(utc) fta=ft; else LocalFileTimeToFileTime &ft &fta
int ok=SetFileTime(hfile pftc pfta pftm)
CloseHandle hfile
if(!ok) end ES_FAILED