VB 版 (精华区)
发信人: zxfsnow (别怕我伤心), 信区: VB
标 题: 文件的创建时间,访问时间,最后修改时间
发信站: 哈工大紫丁香 (2000年05月31日19:59:17 星期三), 转信
--
以科计为发信人: ming (继续睡觉..zzZZ), 信区: VB
标 题: 文件的创建时间,访问时间,最后修改时间
发信站: 虎踞龙盘东南站 (Mon Feb 14 13:25:17 2000), 转信
发信人: erain (红花会主), 信区: VisualBasic
标 题: 文件的创建时间,访问时间,最后修改时间
发信站: BBS 水木清华站 (Wed Jan 5 21:54:53 2000) WWW-POST
UTC是“协同世界时间”(也称为GMT时间,或“格林威治平时”,因为它以英格兰的格林
威治为基础)。
以下程序实现将指定文件的创建时间,访问时间,最后修改时间,改为当前时间
Public 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
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As
Long
Public Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As
SYSTEMTIME, lpFileTime As FILETIME) As Long
Public Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Public Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long,
lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As
FILETIME) As Long
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public 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 Type
Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Function OpenFile(FileName As String) As Long
OpenFile = CreateFile(FileName, GENERIC_READ Or GENERIC_WRITE, 0, 0,
OPEN_EXISTING, 0, 0)
End Function
'取当前本地时间
dim sNowTime as SYSTEMTIME
dim sFileTime as FILETIME
dim hFile as long
getLocalTime sNowTime
'将系统时间转换成文件时间
if SystemTimeToFileTime (sNowTime, sFileTime)=0 then err.....
hFile=openfile("c:\abc.txt")
if SetFileTime (hfile,sFileTime,sFileTime,sFileTime)=0 then er.....
CloseHandle hFile
--
巧者劳而智者忧,无能者无所求,饱食而遨游,泛若不系之舟。
请稍候,正在返璞归真中......
__________________________________________________________________
||||||||||| 20% |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
每一刻都存在,不一样的精彩 本,以产业报国!
超越自我,飞跃无限!
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.235.249]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.187毫秒