GetFileTimeInfoA(string strName)
{
WIN32_FIND_DATA filestruct;
size_t size = strName.length();
wchar_t *buffer = new wchar_t[size+1];
MultiByteToWideChar( CP_ACP, 0, strName.c_str(), size, buffer, size * sizeof(wchar_t) );
buffer[size] = 0; // 确保以 '\0' 结尾
HANDLE hf = FindFirstFile(buffer,&filestruct);
delete buffer;
SYSTEMTIME sysTime;
FILETIME localft;
FILETIME createTime = filestruct.ftCreationTime;
FILETIME lastAccessTime = filestruct.ftLastAccessTime;
FILETIME lastWriteTime = filestruct.ftLastWriteTime;
// 将文件时间转成本地时间
FileTimeToLocalFileTime(&createTime, &localft);
FileTimeToSystemTime(&localft,&sysTime);
printf("创建时间(本地) (YYYY-MM-DD HH:MM:SS): %d-%d-%d %d:%d:%d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
// 将文件时间转成UTC时间 比本地系统时间慢8个小时
FileTimeToSystemTime(&createTime,&sysTime);
printf("创建时间(UTC) (YYYY-MM-DD HH:MM:SS): %d-%d-%d %d:%d:%d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
FileTimeToLocalFileTime(&lastAccessTime, &localft);
FileTimeToSystemTime(&localft,&sysTime);
printf("最后访问时间 (YYYY-MM-DD HH:MM:SS): %d-%d-%d %d:%d:%d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
FileTimeToLocalFileTime(&lastWriteTime, &localft);
FileTimeToSystemTime(&localft,&sysTime);
printf("最后修改时间 (YYYY-MM-DD HH:MM:SS): %d-%d-%d %d:%d:%d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
}