win文件时间问题
2021-06-19 07:05
标签:exist pre pen min 创建时间 err sizeof cal end win文件时间问题 标签:exist pre pen min 创建时间 err sizeof cal end 原文地址:http://blog.51cto.com/haidragon/2344205 FILETIME stLocal;
SYSTEMTIME stsystime;
FILETIME ftCreate, ftModify, ftAccess;
HANDLE hFile = CreateFile(path, GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftModify))
{
G_ST_return_code.Create_File_Error = TRUE;
goto end;
}
ZeroMemory(&stLocal, sizeof(SYSTEMTIME));
FileTimeToLocalFileTime(&ftCreate, &stLocal);
FileTimeToSystemTime(&stLocal, &stsystime);
sprintf(data, "%04d-%02d-%02d %02d:%02d:%02d", stsystime.wYear, stsystime.wMonth, stsystime.wDay, stsystime.wHour, stsystime.wMinute, stsystime.wSecond); // 文件创建时间
S_FileInfo = data;