Delphi-相当于C#DateTime.现在需要Ticks方法



我需要使用delphi中的TSystemTime来知道ticks值。因为我可以通过DateTime在c#中获得相同的值。现在滴答声。因此,我正在寻找一个函数或使用TSystemTime查找ticks值的方法。

如果您有TSystemTime,最简单的方法是将其转换为TFileTime&然后添加偏移。这将得到一个与c#DateTime匹配的值。同时勾选值。

function TSystemTimeToCSharpTicks(sTime: TSystemTime): UInt64;
var
fTime: TFileTime;
begin
SystemTimeToFileTime(sTime, fTime); //Should check if it returns an error.
//Result := UInt64(fTime); Not too sure how safe this is depending on the architecture.
Result := (UInt64(fTime.dwHighDateTime) shl 32) + UInt64(ftime.dwLowDateTime);
Result := Result + 504911232000000000;
end;

相关内容

最新更新