IF FFIsNewer( "bme.rc", "bme.res") THEN PRINT "bme.rc is newer" ELSE PRINT "bme.res is newer" END IF ' ------------------------------------------------------------------------- ' Returns TRUE or FALSE depending on which file(s) is newer ' ------------------------------------------------------------------------- FUNCTION FFIsNewer( File1$, File2$ ) AS BOOL DIM ft1 AS FILETIME DIM ft2 AS FILETIME ' -1 First file time is less than second file time. ' 0 First file time is equal to second file time. ' +1 First file time is greater than second file time. IF NOT GetFileDate(File1$,&ft1) THEN DisplayLastError("Error checking file 1 -> " + File1$ + CR$) IF NOT GetFileDate(File2$,&ft2) THEN DisplayLastError("Error checking file 2 -> " + File2$ + CR$) IF CompareFileTime(&ft1,&ft2) <> 1 THEN FUNCTION = FALSE FUNCTION = TRUE END FUNCTION ' ------------------------------------------------------------------------- ' Fills time struct with date/time info ' ------------------------------------------------------------------------- FUNCTION GetFileDate (filename$, pft AS FILETIME PTR) AS BOOL ' we are interested only in the create time ' this is the equiv of "modified time" in the ' Windows Explorer properties dialog DIM ct AS FILETIME DIM lat AS FILETIME DIM hFile AS HANDLE DIM bret AS BOOL hFile = CreateFile(filename$,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0) IF hFile = INVALID_HANDLE_VALUE THEN DisplayLastError("Invalid file handle" + CR$) IF NOT GetFileTime(hFile,&ct,&lat,pft) THEN DisplayLastError("Error in GetFileTime" + CR$) CloseHandle(hFile) FUNCTION = TRUE END FUNCTION ' ------------------------------------------------------------------------- ' Displays error info ' ------------------------------------------------------------------------- SUB DisplayLastError(err$) dim szErrorMsg as PVOID dim szErrorNo$ IF GetLastError() <> 0 THEN ' allow windows to allocate the buffer FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | _ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, _ GetLastError(), 0, (LPTSTR)&szErrorMsg, 0, NULL) ' convert number into displayable text, then send it to the screen wsprintf(szErrorNo$, "Error: %d", GetLastError()) PRINT szErrorNo$ + " -> " PRINT (CHAR*)szErrorMsg$ PRINT err$ END IF END SUB