Code:
'-------------------------------------------------------------------- ' [ Redates the entire directory ] ' - Handy (needed) when distributing programs ' - Date used to overwrite older copies ' - Time can be used as version info ' - Can be used in PB/DLL or PB/CC ' - Last update: April 24, 2000 '-------------------------------------------------------------------- SUB Redate() EXPORT DIM SourceDrv$,SourceDir$, Files$ DIM Y&, hFile& DIM FileList() AS STRING DIM LocalTime AS FILETIME DIM SystTime AS SYSTEMTIME DIM StampTime AS FILETIME '=========== [ User Area - Make Changes As Required ] =========== ' Choose your paths SourceDrv = "c:" 'Include ':' in the drive name. SourceDir = "mydirectory" ' name only - no back slashes ' Enter your date / time information here. (mm-dd-yyyy) SystTime.wYear = 2000 ' eg: Apr. 24, 2000 SystTime.wMonth = 4 SystTime.wDay = 24 ' Enter your time information here. (hh:mm:ss:mmm) SystTime.wHour = 17 ' eg: 01:01:00 SystTime.wMinute = 1 SystTime.wSecond = 0 SystTime.wMilliseconds = 0 '================================================================= CHDRIVE SourceDrv IF NOT ERR = 0 THEN EXIT FUNCTION CHDIR (SourceDrv & "\" & SourceDIR) Files$ = DIR$(SourceDrv & "\" & SourceDIR & "\*.*") IF Files$ = "" THEN EXIT FUNCTION Y = 0 'Initialize loop variable DO WHILE Files$ <> "" ' Change the File Name as required hFile = CreateFile(BYCOPY Files$, BYVAL %GENERIC_READ OR %GENERIC_WRITE, _ BYVAL 0, BYVAL %NULL, BYVAL %OPEN_ALWAYS, BYVAL %FILE_ATTRIBUTE_NORMAL, BYVAL %NULL) ' Convert system date/time to file structure. SystemTimeToFileTime SystTime, LocalTime ' Convert local file time to correct format for SetFileTime (UTC) LocalFileTimeToFileTime LocalTime, StampTime ' Set the file time SetFileTime BYVAL hFile, BYVAL %NULL, BYVAL %NULL, StampTime ' Finish up with this file. CloseHandle hFile ' Get the next file, if any. IF Files$ = "" THEN EXIT DO Y = Y + 1 REDIM PRESERVE FileList(Y) FileList(Y) = Files$ Files$ = DIR$ LOOP ' That's it. END sub