<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Fehlerhafte Berechnung von Zeitdifferenz mit SYSTEMTIME]]></title><description><![CDATA[<p>Hallo Leute, könnt ihr mir sagen, wieso mir die untenstehende Methode immer eine Sekunde zuviel berechnet? Bsp. Seit der instanzierung des Objekts bis zum jetzigen Zeitpunkt sind genau 156 millisekunden vergangen. Die Methode kommt aber zum Ergebnis: 1 Sekunde + 156 Millisekunden. Hat jemand von euch eine Idee, wieso??</p>
<pre><code class="language-cpp">// -------------------- method for getting the life - time of this instance -------------------
const KRV_Time *KRV_Object::getLifeTime(void) const{
 // declare local variables
 SYSTEMTIME tmCrt,tmCurr,tmDiff;
 FILETIME ftmCrt,ftmCurr,ftmDiff;
 LARGE_INTEGER liCrt,liCurr,liDiff;

 // get the creation- and the current time
 tmCrt = this-&gt;tmCrt;
 GetLocalTime(&amp;tmCurr);

 // covert both SYSTEMTIME - structs into FILETIME - structs
 SystemTimeToFileTime(&amp;tmCrt,&amp;ftmCrt);
 SystemTimeToFileTime(&amp;tmCurr,&amp;ftmCurr);

 // copy both filetime - structs into LARGER_INTEGER - structs
 CopyMemory(&amp;liCurr,&amp;ftmCurr,sizeof(FILETIME));
 CopyMemory(&amp;liCrt,&amp;ftmCrt,sizeof(FILETIME));

 // subtract the creationtime from the currentime
 liDiff.QuadPart = liCurr.QuadPart - liCrt.QuadPart;

 // inverse all operations with the result
 CopyMemory(&amp;ftmDiff,&amp;liDiff,sizeof(LARGE_INTEGER));
 FileTimeToSystemTime(&amp;ftmDiff,&amp;tmDiff);

 // return a pointer to the SYSTEMTIME struct holding the calculated life - time
 return &amp;(this-&gt;tmLife = tmDiff);
}
// --------------------------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/92174/fehlerhafte-berechnung-von-zeitdifferenz-mit-systemtime</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 12:15:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/92174.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Nov 2004 23:14:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehlerhafte Berechnung von Zeitdifferenz mit SYSTEMTIME on Mon, 15 Nov 2004 23:14:53 GMT]]></title><description><![CDATA[<p>Hallo Leute, könnt ihr mir sagen, wieso mir die untenstehende Methode immer eine Sekunde zuviel berechnet? Bsp. Seit der instanzierung des Objekts bis zum jetzigen Zeitpunkt sind genau 156 millisekunden vergangen. Die Methode kommt aber zum Ergebnis: 1 Sekunde + 156 Millisekunden. Hat jemand von euch eine Idee, wieso??</p>
<pre><code class="language-cpp">// -------------------- method for getting the life - time of this instance -------------------
const KRV_Time *KRV_Object::getLifeTime(void) const{
 // declare local variables
 SYSTEMTIME tmCrt,tmCurr,tmDiff;
 FILETIME ftmCrt,ftmCurr,ftmDiff;
 LARGE_INTEGER liCrt,liCurr,liDiff;

 // get the creation- and the current time
 tmCrt = this-&gt;tmCrt;
 GetLocalTime(&amp;tmCurr);

 // covert both SYSTEMTIME - structs into FILETIME - structs
 SystemTimeToFileTime(&amp;tmCrt,&amp;ftmCrt);
 SystemTimeToFileTime(&amp;tmCurr,&amp;ftmCurr);

 // copy both filetime - structs into LARGER_INTEGER - structs
 CopyMemory(&amp;liCurr,&amp;ftmCurr,sizeof(FILETIME));
 CopyMemory(&amp;liCrt,&amp;ftmCrt,sizeof(FILETIME));

 // subtract the creationtime from the currentime
 liDiff.QuadPart = liCurr.QuadPart - liCrt.QuadPart;

 // inverse all operations with the result
 CopyMemory(&amp;ftmDiff,&amp;liDiff,sizeof(LARGE_INTEGER));
 FileTimeToSystemTime(&amp;ftmDiff,&amp;tmDiff);

 // return a pointer to the SYSTEMTIME struct holding the calculated life - time
 return &amp;(this-&gt;tmLife = tmDiff);
}
// --------------------------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/652840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/652840</guid><dc:creator><![CDATA[Ishildur]]></dc:creator><pubDate>Mon, 15 Nov 2004 23:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhafte Berechnung von Zeitdifferenz mit SYSTEMTIME on Tue, 16 Nov 2004 07:55:47 GMT]]></title><description><![CDATA[<p>Beantwortet zwar nicht deine Frage, aber wäre es nicht einfacher / besser gleich GetTickCount zu verwenden, wenn du nur an einer Zeitdifferenz interessiert bist?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/652922</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/652922</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 16 Nov 2004 07:55:47 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhafte Berechnung von Zeitdifferenz mit SYSTEMTIME on Tue, 16 Nov 2004 15:06:51 GMT]]></title><description><![CDATA[<p>Die Klasse KRV_Object enthält aber auch eine Methode &quot;const KRV_Time *getCreationTime(void) const;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/653285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/653285</guid><dc:creator><![CDATA[Ishildur]]></dc:creator><pubDate>Tue, 16 Nov 2004 15:06:51 GMT</pubDate></item></channel></rss>