// 获取最后修改的文件时间
BOOL GetLastWriteTime(HANDLE hFile, LPSTR lpszString)
{
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;
// Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
return FALSE;
// Convert the last-write time to local time.
FileTimeToSystemTime(&ftWrite, &stUTC);
// 转换为本地时间
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
// Build a string showing the date and time.
wsprintf(lpszString, "%02d/%02d/%d %02d:%02d",
stLocal.wDay, stLocal.wMonth, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);
return TRUE;
}
// 如下调用此可获得
HANDLE hFind = CreateFile("c://1.exe",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
HANDLE hFind = CreateFile(sss,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
char chMsg[MAX_PATH];
GetLastWriteTime (hFind,chMsg);
AfxMessageBox(chMsg);