Hello,
Here is the ported version to FBSL v3 :
One cas easily compare the C version vs the FBSL one and have a look at slight difference of both languages
Compiled as 'tiny' Fbsl executable, it's final weight is around 8Kb.
// ********************************
// Author : Gerome GUILLEMIN
// Coded in FBSL v3
// Date : 01st of October 2006
// ********************************
#DllDeclare Kernel32( "CreateFile", "CloseHandle", "GetSystemTime", "SystemTimeToFileTime", "SetFileTime" )
Function Main()
Dim %lngHandle = NULL
Dim $szFileName * MAX_PATH+1
If CommandCount() = 2 Then
StrCpy( szFileName, Command(1) )
lngHandle = CreateFile(szFileName, GENERIC_WRITE, _
FILE_SHARE_READ + FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)
If lngHandle AndAlso lngHandle <> INVALID_HANDLE_VALUE Then
SetFileToCurrentTime( lngHandle )
CloseHandle( lngHandle )
Return 1 // => 1 will be the OK return
End If
End If
Return 0 // => 0 will be the KO return
End Function
Function SetFileToCurrentTime(Byval %hFile)
Dim $ft * 16 'FILETIME
Dim $st * 16 'SYSTEMTIME
GetSystemTime(@st) // gets current time
SystemTimeToFileTime(@st, @ft) // converts to file time format
Return SetFileTime(hFile, 0, 0, @ft) // sets last-write time for file
End Function
See the attached Zip file to get the whole thing.
Enjoy FBSL !