SYSTEMTIME: hinzufügen von Sekunden
-
It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should copy the low- and high-order parts of the file time to a LARGE_INTEGER structure, perform 64-bit arithmetic on the QuadPart member, and copy the LowPart and HighPart members into the FILETIME structure.
Do not cast a pointer to a FILETIME structure to either a LARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows.
Was heißt dass, und wie kann ich das zuzählen???
das habe ich:
FILETIME ftAlarm; GetLocalTime(&stAlarm); SystemTimeToFileTime(&stAlarm,&ftAlarm); // Hinzufügen, aber wie? FileTimeToSystemTime(&ftAlarm,&stAlarm);
-
leute!
was hat es mit diesem Low und high part auf sich???
thx.
-
Ignoriert FILETIME denn Leap-Seconds etc.?
-
hustbaer schrieb:
Ignoriert FILETIME denn Leap-Seconds etc.?
Was sind denn Leap-Seconds???
und wie soll ich die Zeit dazuzählen???
Danke. brauch dringend hilfe.
-
Was sind Leap-Seconds? Lead Seconds sind LÄSTIG:
http://en.wikipedia.org/wiki/Leap_second
-
Naja, ok.
aber ich möchte!! mur wissen, wie ich zu einer FILETIME struktur einen in DWORD variable gespeicherten wert addieren kann.
weil da ist so ein Low und High part.
was ist dass? wie kann ich damit rechnen??
danke.
-
bis jetzt habe ich dass: aber er fügt mir immer nur im 8-minutentakt hinzu.
FILETIME ftAlarm; GetLocalTime(&stAlarm); SystemTimeToFileTime(&stAlarm,&ftAlarm); // Increment file time ftAlarm.dwHighDateTime += dwCount; FileTimeToSystemTime(&ftAlarm,&stAlarm);
-
naja, das einfachste ist, du kopierst die FILETIME in einen __int64 und zählst dann die Zahl dazu; kopierst es wieder zurück in die FILETIME und konvertierst es wieder in die SYSTEMTIME... muss die Funktion bei mir mal suchen, die das macht...
-
aber, wenn man beide (low + high part) in einen __int64 kopiert,
woher will man wissen, wenn man beide zurückkopiert, was in den low und was in den high part muss???
danke.
-
Lies doch bitte die Doku zu FILETIME... da steht es drin... es spielt keine Rolle, was in Low/HighPart drin steht... wichtig ist nur, dass der 64-Bit-Wert eine Zeitangabe seit 1601 in 100 ns ist..
Ungestest:
void AddSec(SYSTEMTIME &st, int sekundenToAdd) { ULONGLONG ull; FILETIME ft; SystemTimeToFileTime(&st, &ft); memcpy(&ull, &ft, min(sizeof(ULONGLONG), sizeof(FILETIME))); ULONLONG ulSecAdd = (ULONGLONG)10000000*(ULONGLONG)sekundenToAdd; ull += ulSecAdd; memcpy(&ft, &ull, min(sizeof(ULONGLONG), sizeof(FILETIME))); FileTimeToSystemTime(&ft, &st); }
-
// Microsoft empfiehlt es so zu machen (warum auch immer, schätze mal wegen endianness): void AddToFiletime(FILETIME& ft, DWORD x) { LARGE_INTEGER li; li.HighPart = ft.dwHighDateTime; li.LowPart = ft.dwLowDateTime; li.QuadPart += x; ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart; }