2.1.10.20 GetFileModificationDate
Description
Get the file modification date of a file from an input string containing
a path and filename.
Get the file modification date of a file from an input string containing
a path and filename.
Syntax
BOOL GetFileModificationDate( LPCSTR lpcstrPathAndFilename, SYSTEMTIME & pSysTime )
string GetFileModificationDate( LPCSTR lpcstrPathAndFilename, WORD wFormat = LDF_SHORT )
Parameters
- lpcstrPathAndFilename
- [input] string containing a path and filename with filetype extension
- pSysTime
- [output] pointer to a SYSTEMTIME structure that will receive the file's modification time
- lpcstrPathAndFilename
- [input] string containing a path and filename with filetype extension
- wFormat
- [input] a date format flag to determine the appearance of the formatted string.
- These includes: LDF_SHORT, LDF_LONG, LDF_ALPHAMONTH_NUMERICDAY, LDF_NUMERICMONTH_NUMERICDAY,
- LDF_NUMERICDAY, LDF_ALPHAWEEKDAY_3CHR, LDF_ALPHAWEEKDAY_1CHR, LDF_NUMERICYEAR_4DIGIT,
- LDF_NUMERICYEAR_2DIGIT, LDF_SHORT_AND_HHMM_SEPARCOLON, LDF_SHORT_AND_HHMMSS_SEPARCOLON,
- LDF_YYMMDD, LDF_YYMMDD_AND_HHMM_SEPARCOLON, LDF_YYMMDD_AND_HHMMSS_SEPARCOLON,
- LDF_YYMMDD_AND_HHMM, LDF_YYMMDD_AND_HHMMSS, LDF_ALPHAMON_3CHR, LDF_ALPHAMON_1CHR,
- LDF_QUARTER, LDF_CUSTOM1, LDF_CUSTOM2 .
- See the definitions of LDF_* in OC_Const.h .
Return
Returns TRUE for success else FALSE for error
Returns a Windows like file modification date formatted for display.
Examples
EX1
void GetFileModificationDate_ex1()
{
string strTempFile;
string strFileDate;
WORD wFormat = LDF_YYMMDD;
GetTempFileName(strTempFile,"ABC");
SYSTEMTIME sysTime;
if( GetFileModificationDate(strTempFile, sysTime) )
{
LPSTR lpstr = strFileDate.GetBuffer(MAXFULLPATH);
if( lpstr )
{
systemtime_to_date_str(&sysTime, lpstr, wFormat);
strFileDate.ReleaseBuffer();
}
}
if(!strFileDate.IsEmpty())
printf("The file is modified in %s",strFileDate);
else
printf("error, the file does not exits");
}
EX2
int GetFileModificationDate_ex2()
{
string strTempFile;
string strFileDate;
GetTempFileName(strTempFile,"ABC");
strFileDate = GetFileModificationDate(strTempFile);
if(!strFileDate.IsEmpty())
printf("The file is modified in %s",strFileDate);
else
printf("error, the file does not exits");
return 0;
}
Remark
See Also
Header to Include
origin.h
Reference
|