怎样真正的修改日期的创建日期

iwillgo2 2003-01-14 12:20:08
怎样真正的修改日期的创建日期
...全文
74 点赞 收藏 8
写回复
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxinghappy 2003-01-16
用API 实现

Public Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FileTime, lpLastAccessTime As FileTime, lpLastWriteTime As FileTime) As Long

SetFileTime
The SetFileTime function sets the date and time that a file was created, last accessed, or last modified.

BOOL SetFileTime(
HANDLE hFile, // handle to 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
);

Parameters
hFile
Handle to the file for which to set the dates and times. The file handle must have been created with GENERIC_WRITE access to the file.
lpCreationTime
Pointer to a FILETIME structure that contains the date and time the file was created. This parameter can be NULL if the application does not need to set this information.
lpLastAccessTime
Pointer to a FILETIME structure that contains the date and time the file was last accessed. The last access time includes the last time the file was written to, read from, or (in the case of executable files) run. This parameter can be NULL if the application does not need to set this information.
lpLastWriteTime
Pointer to a FILETIME structure that contains the date and time the file was last written to. This parameter can be NULL if the application does not want to set this information.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The FAT and NTFS file systems support the file creation, last access, and last write time values.


回复
suntt 2003-01-16
up
回复
2ren 2003-01-15
to: ccbl(XML我来了)
文件copy好像是不行的。必须新建一个文件然后拷贝内容。
回复
ccbl 2003-01-15
看看FSO,先修改需要的系统日期,在将文件COPY 一分就修改文件日期了
回复
lxcc 2003-01-15
.net里有
vb我找了没有
回复
2ren 2003-01-14
不太清楚。但有个笨办法。
先修改系统日期为想要修改为的日期。
然后新建一个文件,并拷贝原文件内容到新文件。
然后删除源文件,更改新文件名为原文件名。
搞定~~~
回复
iwillgo2 2003-01-14
不好意思,太着急了,是修改文件的创建日期
回复
qiuzhongshu 2003-01-14
被前面的前了
那个笨办法是可行的
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7453

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告