zoukankan      html  css  js  c++  java
  • 修改文件创建时间

     1 Option Explicit
     2 
     3 Public Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
     4 Public Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SystemTime, lpFileTime As FILETIME) As Long
     5 Public Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As LongAs Long
     6 Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As LongAs Long
     7 Public Declare Function LocalFileTimeToFileTime Lib "kernel32" (lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
     8 Public Const OF_EXIST = &H4000
     9 Public Const OFS_MAXPATHNAME = 128
    10 Public Const OF_READWRITE = &H2
    11 
    12 Public Type OFSTRUCT
    13     cBytes   As Byte
    14     fFixedDisk   As Byte
    15     nErrCode   As Integer
    16     Reserved1   As Integer
    17     Reserved2   As Integer
    18     szPathName(OFS_MAXPATHNAME)   As Byte
    19 End Type
    20 Public Type FILETIME
    21     dwLowDateTime   As Long
    22     dwHighDateTime   As Long
    23 End Type
    24 
    25 Public Type SystemTime
    26     wYear   As Integer
    27     wMonth   As Integer
    28     wDayOfWeek   As Integer
    29     wDay   As Integer
    30     wHour   As Integer
    31     wMinute   As Integer
    32     wSecond   As Integer
    33     wMilliseconds   As Integer
    34 End Type
    35 
    36 Public Sub ModiFileTime(sFile As String, 日期 As SystemTime)
    37     Dim Rev     As Long
    38     Dim hFile     As Long
    39     Dim fTime     As FILETIME
    40     Dim fLTime     As FILETIME
    41     Dim fStruct     As OFSTRUCT
    42 
    43     Rev = SystemTimeToFileTime(日期, fLTime)
    44     Rev = LocalFileTimeToFileTime(fLTime, fTime)
    45     hFile = OpenFile(sFile, fStruct, OF_READWRITE)
    46     Rev = SetFileTime(hFile, fTime, fTime, fTime)
    47     Rev = CloseHandle(hFile)
    48 End Sub
    49 
    50 '使用方法
    51 Private Sub Form_Load()
    52     Dim 日期     As SystemTime
    53     With 日期       '2008/04/14     20:00:00
    54             .wYear = 2008
    55             .wMonth = 4
    56             .wDay = 14
    57             .wHour = 20
    58             .wMinute = 0
    59             .wSecond = 0
    60     End With
    61     ModiFileTime "C:\1.ico", 日期
    62 End Sub
    63 
  • 相关阅读:
    Java面试题—初级(4)
    Java面试题—初级(3)
    Java面试题—初级(2)
    Java面试题—初级(1)
    在ESXi使用esxcli命令強制关闭VM
    重置mysql的root密码
    通过RHN网站给RHEL打补丁
    Linux命令之rhn_check
    一键GHOST
    Http错误大全
  • 原文地址:https://www.cnblogs.com/xxaxx/p/1635323.html
Copyright © 2011-2022 走看看