C
caojianli
Unregistered / Unconfirmed
GUEST, unregistred user!
两种设置修改时间函数如下:
第一种:
function SetFileDate (TheFileName: string; aDate: string):boolean;
Var
f : HFile;//integer;
ST : TSystemTime;
FT : TFileTime;
Begin
DateTimeToSystemTime(StrToDateTime (aDate), ST);
SystemTimeToFileTime(ST, FT);
LocalFileTimeToFileTime(FT, FT);
f := FileOpen (TheFileName, fmOpenReadWrite or fmShareDenyNone);
Try
SetFileTime(f, @FT, @FT, @FT);
//FileSetDate (f, DateTimeToFileDate ((StrToDateTime (aDate))));
Finally
FileClose (f);
result:=false;
End
End;
第二种:
function SetFileDate (TheFileName: string; aDate: string):boolean;
Var
f : integer;
Begin
f := FileOpen (TheFileName, fmOpenReadWrite);
Try
FileSetDate (f, DateTimeToFileDate ((StrToDateTime (aDate))));
Finally
FileClose (f);
result:=false;
End
End;
试验时间为:2006-08-01 04:34:49 2006-08-01 04:34:53 2006-08-01 04:34:56
2006-08-01 04:34:56这个对 其他两个不对不是多一秒就是少一秒![?]
第一种:
function SetFileDate (TheFileName: string; aDate: string):boolean;
Var
f : HFile;//integer;
ST : TSystemTime;
FT : TFileTime;
Begin
DateTimeToSystemTime(StrToDateTime (aDate), ST);
SystemTimeToFileTime(ST, FT);
LocalFileTimeToFileTime(FT, FT);
f := FileOpen (TheFileName, fmOpenReadWrite or fmShareDenyNone);
Try
SetFileTime(f, @FT, @FT, @FT);
//FileSetDate (f, DateTimeToFileDate ((StrToDateTime (aDate))));
Finally
FileClose (f);
result:=false;
End
End;
第二种:
function SetFileDate (TheFileName: string; aDate: string):boolean;
Var
f : integer;
Begin
f := FileOpen (TheFileName, fmOpenReadWrite);
Try
FileSetDate (f, DateTimeToFileDate ((StrToDateTime (aDate))));
Finally
FileClose (f);
result:=false;
End
End;
试验时间为:2006-08-01 04:34:49 2006-08-01 04:34:53 2006-08-01 04:34:56
2006-08-01 04:34:56这个对 其他两个不对不是多一秒就是少一秒![?]