修改文件创建时间

 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   Long As   Long
 6  Public  Declare  Function  CloseHandle Lib  " kernel32 "  (ByVal hObject  As   Long As   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 

 

转载于:https://www.cnblogs.com/xxaxx/archive/2009/12/29/1635323.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值