[Plain Text] 纯文本查看 复制代码
BOOL WINAPI GetFileTime(
__in HANDLE hFile,
__out_opt LPFILETIME lpCreationTime,
__out_opt LPFILETIME lpLastAccessTime,
__out_opt LPFILETIME lpLastWriteTime
);
[C++] 纯文本查看 复制代码
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hFile;
FILETIME Creation, Access, LastWrite;
SYSTEMTIME SystemTime;
hFile = CreateFile (_T("a.txt"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
GetFileTime(hFile, &Creation, &Access, &LastWrite);
FileTimeToSystemTime (&Creation, &SystemTime);
_ftprintf(stdout, _T("File creation time is: %d/%d/%d/ %d:%d\n"), SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour+8, SystemTime.wMinute);
FileTimeToSystemTime (&Access, &SystemTime);
_ftprintf(stdout, _T("File Access time is: %d/%d/%d/ %d:%d\n"), SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour+8, SystemTime.wMinute);
FileTimeToSystemTime (&LastWrite, &SystemTime);
_ftprintf(stdout, _T("File last write time is: %d/%d/%d/ %d:%d\n"), SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour+8, SystemTime.wMinute);
return 0;
}