- WinCE Security...
- xdebug配置说明
- VC++ 获取文件的创建、修...
- ASP进度条
- 简单代理服务器C代码实现(S...
- 程序设计竞赛试题选(02)
- 如何在ASP程序中打印Acc...
- UTF-8和16进制区间
- ASP实用技巧:强制刷新和判...
- 运行中程序删除自己的方法
- asp提高首页性能的一个技巧
- [J2EE]J2EE 应用服务器技术
- VB变量命名规范
- C语言常见错误小结
- (摘自网络)如何在IIS中调...
VC++ 获取文件的创建、修改、访问时间
由于在Windows系统中,FAT与NTFS保存文件时间的格式不相同:
FAT records times on disk in local time. However, NTFS records times on disk in UTC.
故必须按如下步骤,获取文件时间,仅参考:
HANDLE hFile = CreateFile(strFilePathName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
FILETIME ftCreate,ftModify,ftAccess,ftLocal;
SYSTEMTIME sysTime;
GetFileTime(hFile, &ftCreate, &ftAccess, &ftModify); //
FileTimeToLocalFileTime(&ftCreate, &ftLocal); //
FileTimeToSystemTime(&ftLocal, &sysTime);
CString strHint = "";
CString strOemTime = "";
strHint.Format("%d年%d月%d日, %d:%d:%d:%d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strOemTime.Format("%04d%02d%02d%02d%02d%02d%03d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strHint += ("\r\n" + strOemTime);
SetDlgItemText(IDC_EDIT_CREATETIME, strHint);
strHint.Empty(); //
FileTimeToLocalFileTime(&ftModify, &ftLocal); //
FileTimeToSystemTime(&ftLocal, &sysTime);
strHint.Empty();
strHint.Format("%d年%d月%d日, %d:%d:%d:%d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strOemTime.Empty();
strOemTime.Format("%04d%02d%02d%02d%02d%02d%03d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strHint += ("\r\n" + strOemTime);
SetDlgItemText(IDC_EDIT_MODIFYTIMER, strHint);
strHint.Empty(); //
FileTimeToLocalFileTime(&ftAccess, &ftLocal); //
FileTimeToSystemTime(&ftLocal, &sysTime);
strHint.Empty();
strHint.Format("%d年%d月%d日, %d:%d:%d:%d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strOemTime.Empty();
strOemTime.Format("%04d%02d%02d%02d%02d%02d%03d", sysTime.wYear, sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute, sysTime.wSecond,sysTime.wMilliseconds);
strHint += ("\r\n" + strOemTime);
SetDlgItemText(IDC_EDIT_ACCESSTIME, strHint);
CloseHandle(hFile);
}