Set File's Last-Written Date and Time





QuickBasic


' DOS 2+ - SET FILE'S LAST-WRITTEN DATE AND TIME

'$INCLUDE: 'qb.bi'

DIM file AS STRING
DIM inregs  AS RegTypeX
DIM outregs AS RegTypeX

file = "C:\INT\124.txt" + CHR$(0)
inregs.CX = 32
inregs.DS = VARSEG(file)
inregs.DX = SADD(file)
inregs.AX = &H3C00

CALL InterruptX(&H21, inregs, outregs)

IF outregs.FLAGS AND 1 THEN
   PRINT "Error creating >> " + file$
   BEEP: END
END IF

DIM FileHandle AS INTEGER
FileHandle = outregs.AX

inregs.AX = &H5701
inregs.BX = FileHandle

'does not work in DOSBox

inregs.CX = 100  ' new time
' Bits
'  15-11  hours (0-23)
'  10-5   minutes
'  4-0    seconds/2

inregs.DX = 100  ' new date
' Bits
'  15-9   year - 1980
'  8-5    month
'  4-0    day

' DOS interrupt with sub-function &H5701

CALL InterruptX(&H21, inregs, outregs)

IF outregs.FLAGS AND 1 THEN
   PRINT "Error setting date and time >> " + file
   BEEP: END
END IF