I want a piece of function which will take a file and last how many days, if it was older than that date, will return 0 otherwise 1… Something like that…
For example:
int IsOlder(TCHAR *filename, int days)
{
do operation.
If last modify date was older than days variable
return 0
else
return 1
}
It’s MS VC++ 6 for Windows.
Thanks from now!
Windows has an API function called
GetFileTime()(doc on MSDN) taking a file handle in parameter and 3FILETIMEstructures to be filled with date-time info:The
FILETIMEstructure is obfuscated, use the functionFileTimeToSystemTime()to translate it to aSYSTEMTIMEstructure which is way easier to use:Then you can use fields
wYear,wMonth, etc. to compare with your number of days.