📄 4633.html
字号:
<html>
<head>
<title>请【笑儿】进来看看好吗?^_^..</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>请【笑儿】进来看看好吗?^_^..</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by 小顺子 on August 12, 1998 at 03:21:38:<p>
In Reply to: <a href="4621.html">Re: 请问【修改】档案的建立日期、时间?</a> posted by 笑儿 on August 11, 1998 at 21:45:04:<p>
这个主要功能是由 API 更改档案的建立时间,<br>虽然我可以读取时间,也找了相对的 API<br>可是不论如何嚐试,就是无法写入,不知道<br>SetFileTime Lib "kernel32" 更改档案时<br>间是要如何设定呢?<p><br>'表单上有 Command1 和 Command2 , 并须要建立一个测试档案<br>Option Explicit<p>Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, _<br> lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long<br>Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) _<br> As Long<p>Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As _<br> FileTime, lpSystemTime As SYSTEMTIME) As Long<br>Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As _<br> SYSTEMTIME, lpFileTime As FileTime) As Long<br> <br>Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, _<br> lpCreationTime As FileTime, lpLastAccessTime As FileTime, _<br> lpLastWriteTime As FileTime) As Long<br>Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, _<br> lpCreationTime As FileTime, lpLastAccessTime As FileTime, _<br> lpLastWriteTime As FileTime) As Long<p>Const OFS_MAXPATHNAME = 128<br>Const OF_READ = &H0<br>Dim FileHandle As Long<p>Private lpReOpenBuff As OFSTRUCT<br>Private Type OFSTRUCT<br> cBytes As Byte<br> fFixedDisk As Byte<br> nErrCode As Integer<br> Reserved1 As Integer<br> Reserved2 As Integer<br> szPathName(OFS_MAXPATHNAME) As Byte<br>End Type<p>Private ft As SYSTEMTIME<br>Private Type SYSTEMTIME<br> wYear As Integer<br> wMonth As Integer<br> wDayOfWeek As Integer<br> wDay As Integer<br> wHour As Integer<br> wMinute As Integer<br> wSecond As Integer<br> wMilliseconds As Integer<br>End Type<p>Private Type FileTime<br> dwLowDateTime As Long<br> dwHighDateTime As Long<br>End Type<p>'更改档案时间资讯<br>Private Sub Command1_Click()<br>Dim cre As FileTime '建立<br>Dim acc As FileTime '修改<br>Dim wri As FileTime '存取<br>Dim myfile As String '测试档案<br> myfile = "f:\0000.txt"<br> FileHandle = OpenFile(myfile, lpReOpenBuff, OF_READ) '先取得 File 的 Handle<br> '这里要如何写呢?<br> '我试了很多方法,可是档案的时间仍没有改变...<br> Call SetFileTime(FileHandle, cre, acc, wri) '更改时间资料<br> Call CloseHandle(FileHandle)<br>End Sub<p>'取得档案时间资讯<br>Private Sub Command2_Click()<br>Dim cre As FileTime '建立<br>Dim acc As FileTime '修改<br>Dim wri As FileTime '存取<br>Dim mycr As Date '格林威治时间<br>Dim myfile As String '测试档案<br> myfile = "f:\0000.txt"<br> FileHandle = OpenFile(myfile, lpReOpenBuff, OF_READ) '取得 File 的 Handle<br> Call GetFileTime(FileHandle, cre, acc, wri) '取得时间资料<br> Call CloseHandle(FileHandle)<br> Call FileTimeToSystemTime(cre, ft) '转换时间资料结构<br> mycr = DateSerial(ft.wYear, ft.wMonth, ft.wDay) + _<br> TimeSerial(ft.wHour, ft.wMinute, ft.wSecond) '转换时间格式<br> MsgBox mycr<br>End Sub
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 4633-->
<!--top: 4661--><li><a href="4661.html">Re: 请【笑儿】进来看看好吗?^_^..</a> <b>笑儿</b> <i>17:56:22 8/12/98</i>
(<!--responses: 4661-->2)
<ul><!--insert: 4661-->
<!--top: 4672--><li><a href="4672.html">CreateFile 和 OpenFile 的不同?</a> <b>小顺子</b> <i>04:44:35 8/13/98</i>
(<!--responses: 4672-->1)
<ul><!--insert: 4672-->
<!--top: 4673--><li><a href="4673.html">Re: CreateFile 和 OpenFile 的不同?</a> <b>笑儿</b> <i>05:09:11 8/13/98</i>
(<!--responses: 4673-->0)
<ul><!--insert: 4673-->
</ul><!--end: 4673-->
</ul><!--end: 4672-->
</ul><!--end: 4661-->
</ul><!--end: 4633-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -