因为要写工作日总结,以前的都没有写,今天要一起给补上.总结的形式是一个一个的word文档,要是让老板看到它们都是一天建的就不好了。所以才想到用程序来修改这三个时间.
我用filesystemobject得到file,但是file的datecreated/datelastaccessd/datelastmodified都是只读属性。怎么才能改呢?希望跟大家探讨探讨.

解决方案 »

  1.   

    【声明】
    Public Declare Function SetFileTime Lib "kernel32" Alias "SetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
    【说明】
    设置文件的创建、访问及上次修改时间
    【返回值】
    Long,非零表示成功,零表示失败。会设置GetLastError
    【参数表】
      hFile ----------  Long,系统文件句柄  lpCreationTime -  FILETIME,文件的创建时间  lpLastAccessTime -  FILETIME,文件上一次访问的时间  lpLastWriteTime -  FILETIME,文件最近一次修改的时间
      

  2.   

    以下是要用到的API函数,如果还不能解决,mail to :[email protected]
    我发个测试程序给你。'用于改变文件创建日期,最后修改日期的API,数据类型及常量。
    Private Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
    End TypePublic Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
    End TypePrivate Const GENERIC_READ = &H80000000
    Private Const GENERIC_WRITE = &H40000000
    Private Const OPEN_EXISTING = 3
    Private Const FILE_SHARE_READ = &H1
    Private Const FILE_SHARE_WRITE = &H2'获取文件句柄
    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
                             ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
                             ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, _
                             ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
    '获取文件UTC时间信息中的创建日期和最后修改日期
    Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, _
                             ByVal lpLastAccessTime As Long, lpLastWriteTime As FILETIME) As Long
    '设置文件创建日期,最后修改日期
    Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, _
                             lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
    '将系统日期格式转换成本地日期格式
    Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, _
                             lpFileTime As FILETIME) As Long
    '将本地日期格式转换成系统日期格式
    Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, _
                             lpSystemTime As SYSTEMTIME) As Long
    '将UTC时间信息转换成本也时间信息
    Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, _
                             lpLocalFileTime As FILETIME) As Long
    '将本地文件时间转成UTC时间信息
    Private Declare Function LocalFileTimeToFileTime Lib "kernel32" (lpLocalFileTime As FILETIME, _
                             lpFileTime As FILETIME) As Long
    '关闭文件
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
      

  3.   

    不用记,根本不用记,不就是改时间那点事吗?听我的,把系统时间改喽,剩下的嘛,^c&^v,说正经的,有分吧?
      

  4.   

    he SetFileTime function sets the date and time that a file was created, last accessed, or last modified. 
    BOOL SetFileTime(    HANDLE hFile, // identifies the file 
        CONST FILETIME *lpCreationTime, // time the file was created 
        CONST FILETIME *lpLastAccessTime, // time the file was last accessed 
        CONST FILETIME *lpLastWriteTime  // time the file was last written 
       );