VC++常用功能封装代码一系列文章与源码 (打广告,哈哈,看看一系列再决定要不要订阅)
https://blog.csdn.net/kaizi318/article/details/108846326
源代码demo已上传到百度网盘:永久生效 ,代码实现了获取文件最后的修改时间,返回CString 日期字符串
主要是用到了以下函数:
FileTimeToLocalFileTime(&ffd.ftLastWriteTime, &LocalFileTimel);
FileTimeToSystemTime(&LocalFileTimel, &st);
当然你也可以用其它的方法,比如获取文件属性
其实这个功能主要是用在界面显示上,或者需要比较文件时,其它,用在什么地方.......
上代码:
#include <shlwapi.h>
#include <fileapi.h>
inline CString GetFileLastModifyTime(LPCTSTR strPath)
{
if (!::PathFileExists(strPath))
{
return _T("");
}
WIN32_FIND_DATA ffd ;
HANDLE hFind = FindFirstFile(strPath,&ffd);