#include <windows.h>
#include <stdio.h>
//----------- Error Handling Function -------------------
void error(LPSTR lpszFunction)
{
CHAR szBuf[80];
DWORD dw = GetLastError();
snprintf(szBuf, sizeof(szBuf), "%s failed: GetLastError returned %u\n",lpszFunction, dw);
MessageBox(NULL, szBuf, "Error", MB_OK);
ExitProcess(dw);
}
//--------------------------------------------------------
bool GetFileTime(HANDLE hFile, LPSTR lpszCreationTime, LPSTR lpszLastAccessTime, LPSTR lpszLastWriteTime)
{
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC1, stLocal1, stUTC2, stLocal2, stUTC3, stLocal3;
// -------->获取 FileTime
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite)){
error((LPSTR)"GetFileTime()");
return FALSE;
}
//---------> 转换: FileTime --> LocalTime
FileTimeToSystemTime(&ftCreate, &stUTC1);
FileTimeToSys
C++(18):获取windows下文件的创建/修改/访问时间
最新推荐文章于 2023-10-10 17:05:30 发布