【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.1.8.10 FileTimeToSystemTime
Contents
Description
Converts a 64-bit file time (in form of a FILETIME structure) to system time format.
Syntax
BOOL FileTimeToSystemTime( const FILETIME * lpFileTime, SYSTEMTIME * lpSystemTime )
Parameters
- lpFileTime
- [input] the pointer to the 64-bit file time (usually obtained from GetFileAttributesEx() function as one of the members of the WIN32_FILE_ATTRIBUTE_DATA structure).
- lpSystemTime
- [output] the pointer to the SYSTEMTIME structure which will receive the result. The members of SYSTEMTIME structure provide a human-readable form of date and time.
Return
nonzero for success, 0 for failure.
Examples
EX1
// The example displays system time of one file. int FileTimeToSystemTime_ex1() { string strFile = "c:\\myfile.txt"; ///Create new file HANDLE hFile; hFile = CreateFile( strFile, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { out_str("Could not Create file."); // process error return -1; } CloseHandle(hFile); WIN32_FILE_ATTRIBUTE_DATA fileInfo; // Get the attributes structure of the file if ( GetFileAttributesEx(strFile, 0, &fileInfo) ) { SYSTEMTIME stSystemTime; // Convert the last access time to SYSTEMTIME structure: if ( FileTimeToSystemTime(&fileInfo.ftLastAccessTime, &stSystemTime) ) { printf("Year = %d, Month = %d, Day = %d, Hour = %d, Minute = %d\n", stSystemTime.wYear, stSystemTime.wMonth, stSystemTime.wDay, stSystemTime.wHour, stSystemTime.wMinute); } } else out_str("Cannot get file attributes!"); return 1; }
Remark
See Also
Header to Include
origin.h