我想检索文件上的最后写入日期。我已经写了此代码,但它返回我在52428像值“年”的所有时间C++系统时间返回相同的错误值
int LastErrorCode;
LPCSTR Path = "C:/Users/Username/Desktop/Picture.PNG";
WIN32_FIND_DATA Information;
if(!FindFirstFile(Path, &Information))
{
int LastErrorCode = GetLastError();
cout << "FIND FIRST FILE FAILED" << endl;
cout << LastErrorCode << endl;
}
SYSTEMTIME MyTime;
FILETIME MyFileTime = Information.ftLastWriteTime;
if(!FileTimeToSystemTime(&MyFileTime, &MyTime))
{
LastErrorCode = GetLastError();
cout << "FILE TIME TO SYSTEM TIME FAILED" << endl;
cout << LastErrorCode << endl;
}
cout << MyTime.wYear << endl;
嘿。 FileTimeToSystemTime失败,我得到错误代码87,意思是“参数不正确。”。我不知道什么是错的。 *我已更新回答中的代码 – Janman
@Janman:我添加了更多信息。我怀疑你对FindFirstFile的调用失败(结果不是“布尔”类型)。 –