- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 取 UTC/TFileTime 时间
// 取 UTC/TFileTime 时间
function GetUTCTickCount: Int64;
var
UtcFt: _FILETIME;
begin
// 精确到 100ns = 千万分之一秒
// 返回与 GetTickCount 一样的毫秒
GetSystemTimeAsFileTime(UtcFt);
Result := (Int64(UtcFt) div 10000); // 1,000,000,0
end;
function GetUTCTickCountEh(Seed: Pointer): UInt64;
var
UtcFt: _FILETIME;
begin
// 精确到千万分之一秒,与 Seed 运算产生唯一值
GetSystemTimeAsFileTime(UtcFt);
if (Seed <> nil) then
{$IFDEF WIN_64}
UInt64(UtcFt) := UInt64(UtcFt) xor UInt64(Seed);
{$ELSE}
UtcFt.dwLowDateTime := UtcFt.dwLowDateTime xor LongWord(Seed);
{$ENDIF}
Result := UInt64(UtcFt);
end;