![]() |
Windows.GetTickCount64 auch unter Windows XP?
Heute habe ich das erste mal von Windows.GetTickCount64 gehört. Kann man das auch unter Windows XP nutzen oder benötigt man für Windows XP diesen Workaround?
![]() |
AW: Windows.GetTickCount64 auch unter Windows XP?
Was steht dort
![]() Also ja, vor Windows 8 gibt es das nicht und man braucht was Anderes. |
AW: Windows.GetTickCount64 auch unter Windows XP?
Heißt also das Andere ist dein Code da oben? :P
Braucht man denn irgendwelche Fallunterscheidungen je nach Betriebssystem oder kann man einfach die Unit oben nutzen? Wenn ich das hier richtig verstehe sollte das doch schon als "Fallunterscheidung" reichen
Delphi-Quellcode:
GetTickCount64 := GetProcAddress(GetModuleHandle('Kernel32.dll'), 'GetTickCount64'); // Für alles ab Windows 8
if @GetTickCount64 = nil then // für alles vor Windows 8 // |
AW: Windows.GetTickCount64 auch unter Windows XP?
Jupp, entweder die WinAPI oder wenn nicht existent, dann wird automatisch die Ersatzfunktion verwendet.
|
AW: Windows.GetTickCount64 auch unter Windows XP?
Hier gibt es dazu noch einen Artikel mit Workarounds:
![]() |
AW: Windows.GetTickCount64 auch unter Windows XP?
Zacherl, dein Artikel hat mich neugierig gemacht und die Schnelligkeit von _GetTickCount64 geprüft.
bei 999.999 aufrufen dauert die Ausführung schon knapp 400ms. Windows.GetTickCount54 braucht nur knapp 25ms. |
AW: Windows.GetTickCount64 auch unter Windows XP?
Welche der Versionen hast du denn verwendet? Die mit dem manuellen Overflow Check sollte die Performance nicht nennenswert verschlechtern (laut Artikel ist sie ja angablich sogar besser als die native
![]() |
AW: Windows.GetTickCount64 auch unter Windows XP?
Ich habe himitu's Version (Link erster Beitrag) verwendet. Mit den anderen kann ich nichts anfangen, da es kein Delphi-Code ist.
Mehr als das hier bekomme ich nicht hin und selbst das ist bestimmt noch falsch
Delphi-Quellcode:
var
high, lastLow: Int64; begin high := 0; low := GetTickCount(); if lastLow > low then // high += 0x100000000I64; ... lastLow = low; // return high | (ULONGLONG)low; end; |
AW: Windows.GetTickCount64 auch unter Windows XP?
Sollte in etwa so aussehen:
Delphi-Quellcode:
Ist etwas weniger als halb so performant wie die native Funktion, aber immer noch deutlich schneller als mit
threadvar
High: UInt64; LastLow: Cardinal; function _GetTickCount64: UInt64; inline; var Low: Cardinal; begin Low := GetTickCount; if (LastLow > Low) then begin High := High + $0000000100000000; end; LastLow := Low; Result := High or Low; end; ![]()
Delphi-Quellcode:
auch durch
threadvar
Delphi-Quellcode:
ersetzen - dann ist die Funktion in etwa gleich schnell wie die native Variante.
var
|
AW: Windows.GetTickCount64 auch unter Windows XP?
Ich habe das jetzt so gelößt
Delphi-Quellcode:
unit uGetTickCount64;
interface uses Winapi.Windows, System.SysUtils; threadvar High: UInt64; LastLow: Cardinal; type TGetTickCount = class public class function GetTickCount64: UInt64; inline; end; implementation class function TGetTickCount.GetTickCount64: UInt64; var Low: Cardinal; begin if System.SysUtils.TOSVersion.Major >= 6 then // alles ab Windows Vista Result := Winapi.Windows.GetTickCount64 else // alles vor Windows Vista begin Low := GetTickCount; if (LastLow > Low) then High := High + $0000000100000000; LastLow := Low; Result := High or Low; end; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:38 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz