我的效用是比较来源和目的地档案日期/时间。 在大多数情况下,这都是在比较不同时区档案的日期/时间时失败的。 因此,我需要一个UTC日常工作。
视视之,视窗APICTI GetFiletime将支持这项工作。 我也发现了这一包裹程序,但在2010年Delphi汇编时,它坠毁了GetFiletime电话。
任何想法? 或者,任何人都有一套处理美国金枪鱼养护委时间区的法规,因此,如果存在不同,我可以把2个名字传给我?
function CompareFileTimes(File1, File2 : String) : LongInt;
var
F1, F2 : THandle;
F1_CreateTime,
F1_LastAccess,
F1_LastWrite,
F2_CreateTime,
F2_LastAccess,
F2_LastWrite : PFileTime;
begin
//Initialize all variables
F1 := 0;
F2 := 0;
//Since these are pointers, we have to
//allocate memory for the FileTime structures
GetMem(F1_CreateTime, SizeOf(TFileTime));
GetMem(F1_LastAccess, SizeOf(TFileTime));
GetMem(F1_LastWrite, SizeOf(TFileTime));
GetMem(F2_CreateTime, SizeOf(TFileTime));
GetMem(F2_LastAccess, SizeOf(TFileTime));
GetMem(F2_LastWrite, SizeOf(TFileTime));
//Fill the structures with nulls for now
FillChar(F1_CreateTime, SizeOf(TFileTime), #0);
FillChar(F1_LastAccess, SizeOf(TFileTime), #0);
FillChar(F1_LastWrite, SizeOf(TFileTime), #0);
FillChar(F2_CreateTime, SizeOf(TFileTime), #0);
FillChar(F2_LastAccess, SizeOf(TFileTime), #0);
FillChar(F2_LastWrite, SizeOf(TFileTime), #0);
//Get file handles for the files in question
//Notice that even though we re using CreateFile
//the open disposition for the file is OPEN_EXISTING
F1 := CreateFile(PChar(F1), 0, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
F2 := CreateFile(PChar(F2), 0, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
//Get the file times for the files.
GetFileTime(F1, F1_CreateTime, F1_LastAccess, F1_LastWrite);
GetFileTime(F2, F2_CreateTime, F2_LastAccess, F2_LastWrite);
//Assign the function s result to comparison
//-1, File1 is younger than File2
//0, File1 is the same as File2
//+1 File1 is older than File2
Result := CompareFileTime(F1_CreateTime^, F2_CreateTime^);
//Free the memory allocated to the pointers
FreeMem(F1_CreateTime, SizeOf(TFileTime));
FreeMem(F1_LastAccess, SizeOf(TFileTime));
FreeMem(F1_LastWrite, SizeOf(TFileTime));
FreeMem(F2_CreateTime, SizeOf(TFileTime));
FreeMem(F2_LastAccess, SizeOf(TFileTime));
FreeMem(F2_LastWrite, SizeOf(TFileTime));
end;
任何帮助都将受到高度赞赏。