zoukankan      html  css  js  c++  java
  • 获得文件最后修改日期

    // 获取最后修改的文件时间
    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);

  • 相关阅读:
    mysql导出导入数据库和表学习笔记
    gitlab+jenkins学习笔记
    mysql数据库的备份与恢复
    第十二天python3 匿名函数
    第十三天python3 生成器yield
    [Todo]Java反序列化-weblogic
    bcrypt浅析
    AWD准备
    Linux下提权练习
    wordpress站点被恶意重定向
  • 原文地址:https://www.cnblogs.com/tyjsjl/p/2156088.html
Copyright © 2011-2022 走看看