Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
PROCEDURE Touch( pcFileName, ptDateTime )
* This is based on VB code found here:
* http://www.blackbeltvb.com/free/setftime.htm
#DEFINE OF_WRITE 0x0001
#DEFINE OFS_MAXPATHNAME 128
Declare LONG CloseHandle IN "kernel32" LONG hObject
Declare LONG GetFileTime IN "kernel32" LONG hFile, ;
STRING @ FILETIME_lpCreationTime, ;
STRING @ FILETIME_lpLastAccessTime, ;
STRING @ FILETIME_lpLastWriteTime
Declare LONG OpenFile IN "kernel32" ;
STRING @ lpFileName, ;
STRING @ OFSTRUCT_lpReOpenBuff, ;
LONG wStyle
*' Note I've changed the lpLastAccessTime from a FILETIME to a LONG, because I'm going to pass a 0 (Null)
*'cause I don't want to set it.
Declare LONG SetFileTime IN "kernel32" LONG hFile, ;
STRING @ FILETIME_lpCreationTime, ;
LONG lpLastAccessTime, ;
STRING @ FILETIME_lpLastWriteTime
Declare LONG FileTimeToSystemTime IN "kernel32" ;
STRING @ FILETIME_lpFileTime, ;
STRING @ SYSTEMTIME_lpSystemTime
Declare LONG SystemTimeToFileTime IN "kernel32" ;
STRING @ SYSTEMTIME_lpSystemTime, ;
STRING @ FILETIME_lpFileTime
LOCAL hFile, OFS, lnL, cTime, lTime, lwTime, sTime
LOCAL lcOFS, lcFileName, lc_cTime, lc_lTime, lc_lwTime
OFS = CREATEOBJECT('OFSTRUCT')
lcOfs = OFS.Structure
lcFileName = alltrim(pcFileName)+chr(0)
hFile = OpenFile(@lcFilename, @lcOFS, OF_WRITE)
If hFile <= 0
RETURN .F.
ELSE
cTime = CREATEOBJECT('FILETIME')
lTime = CREATEOBJECT('FILETIME')
lwTime = CREATEOBJECT('FILETIME')
lc_cTime = cTime.Structure
lc_lTime = lTime.Structure
lc_lwTime = lwTime.Structure
lnL=GetFileTime(hFile, lc_cTime, lc_lTime, lc_lwTime)
cTime.Structure = lc_cTime
lTime.Structure = lc_lTime
lwTime.Structure = lc_lwTime
sTime = CREATEOBJECT('SYSTEMTIME')
lc_sTime = sTime.Structure
DECLARE GetLocalTime IN Win32API STRING @ LPSYSTEMTIME_lpSystemTime
GetLocalTime(@lc_sTime)
sTime.Structure = lc_sTime
ltLocalTime = DateTime( sTime.fld('wYear'), sTime.fld('wMonth'), sTime.fld('wDay'), ;
sTime.fld('wHour'), sTime.fld('wMinute'), sTime.fld('wSecond') )
*!* ?'Year=',sTime.fld('wYear')
*!* ?'Month=',sTime.fld('wMonth')
*!* ?'Day=',sTime.fld('wDay')
*!* ?'Hour=',sTime.fld('wHour')
*!* ?'Min=',sTime.fld('wMinute')
*!* ?'Sec=',sTime.fld('wSecond')
DECLARE GetSystemTime IN Win32API STRING @ LPSYSTEMTIME_lpSystemTime
GetSystemTime(@lc_sTime)
sTime.Structure = lc_sTime
ltSysTime = DateTime( sTime.fld('wYear'), sTime.fld('wMonth'), sTime.fld('wDay'), ;
sTime.fld('wHour'), sTime.fld('wMinute'), sTime.fld('wSecond') )
ltBias = (ltSysTime - ltLocalTime)
ltTimeToSet = ptDateTime + ltBias
*!* ?'Year=',sTime.fld('wYear')
*!* ?'Month=',sTime.fld('wMonth')
*!* ?'Day=',sTime.fld('wDay')
*!* ?'Hour=',sTime.fld('wHour')
*!* ?'Min=',sTime.fld('wMinute')
*!* ?'Sec=',sTime.fld('wSecond')
lnL=FileTimeToSystemTime(@lc_lwTime, @lc_sTime)
sTime.Structure = lc_sTime
sTime.fld('wYear') = Year(ltTimeToSet)
sTime.fld('wMonth') = Month(ltTimeToSet)
sTime.fld('wDay') = Day(ltTimeToSet)
sTime.fld('wHour') = Hour(ltTimeToSet)
sTime.fld('wMinute') = Minute(ltTimeToSet)
sTime.fld('wSecond') = Sec(ltTimeToSet)
lc_sTime = sTime.Structure
lnL = SystemTimeToFileTime( @lc_sTime, @lc_lTime )
lnL=SetFileTime(hFile, @lc_cTime, 0, @lc_lTime)
lnL=CloseHandle(hFile)
EndIf
RETURN .T.
ENDPROC
*' OpenFile() Structure
DEFINE CLASS OFSTRUCT AS Struct
PROCEDURE Init
THIS.AddField( 'cBytes', 'BYTE', 0 )
THIS.AddField( 'fFixedDisk', 'BYTE', 0 )
THIS.AddField( 'nErrCode', 'INTEGER', 0 )
THIS.AddField( 'Reserved1', 'INTEGER', 0 )
THIS.AddField( 'Reserved2', 'INTEGER', 0 )
THIS.AddField( 'szPathName', 'STRING', REPL(chr(0),OFS_MAXPATHNAME) )
THIS.fld('cBytes') = Len(THIS.Structure)
ENDPROC
ENDDEFINE
DEFINE CLASS FILETIME AS Struct
PROCEDURE Init
THIS.AddField( 'dwLowDateTime', 'LONG', 0 )
THIS.AddField( 'dwHighDateTime', 'LONG', 0 )
ENDPROC
ENDDEFINE
DEFINE CLASS SYSTEMTIME AS Struct
PROCEDURE Init
THIS.AddField( 'wYear', 'INTEGER', 0 )
THIS.AddField( 'wMonth', 'INTEGER', 0 )
THIS.AddField( 'wDayOfWeek', 'INTEGER', 0 )
THIS.AddField( 'wDay', 'INTEGER', 0 )
THIS.AddField( 'wHour', 'INTEGER', 0 )
THIS.AddField( 'wMinute', 'INTEGER', 0 )
THIS.AddField( 'wSecond', 'INTEGER', 0 )
THIS.AddField( 'wMilliseconds', 'INTEGER', 0 )
ENDPROC
ENDDEFINE