<?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[Zeitdifferenz mit wSecond]]></title><description><![CDATA[<p>Hallo,<br />
ich will die Laufzeit meines Programms berechnen, jedoch geht es mir nicht um irgendwelche Millisekunden um die Geschwindigkeit zu testen sondern um eine längere Laufzeit von mehreren Stunden.</p>
<p>ich habe folgendes probiert.</p>
<pre><code class="language-cpp">GetLocalTime (&amp;st_start);
GetLocalTime (&amp;st_aktuell);

double dif=st_aktuell.wSecond-st_start.wSecond;

char *Laufzeit;
Laufzeit = new char[80];

char buffer2[20];
_itoa( dif, buffer2, 10 );
lstrcpy (Laufzeit, &quot;&quot;);
strcat( Laufzeit, buffer2 );

TextOut(hDC2,tabelle_x+325+200,tabelle_y+210,Laufzeit,strlen(Laufzeit));
</code></pre>
<p>soweit so gut (ich weiss, dass ich damit bisher nur die Zeitdifferenz der Sekunden berechne) jetzt geht es aber los ... ist die Sekundenzeit aktuell = 58<br />
und die Startzeit 34 hat man die gewollte differenz von 24 Sekunden.</p>
<p>Springt aber die aktuelle zeit um auf 1 dann ist die aktuelle Zeit als die Startzeit und ich bekomme als Sekundenwert -33 ... das darf natürlich so nicht sein.</p>
<p>Wie kann ich das verhindern?<br />
MISCHU</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/67247/zeitdifferenz-mit-wsecond</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 05:02:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/67247.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Mar 2004 14:56:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zeitdifferenz mit wSecond on Sat, 06 Mar 2004 14:56:37 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich will die Laufzeit meines Programms berechnen, jedoch geht es mir nicht um irgendwelche Millisekunden um die Geschwindigkeit zu testen sondern um eine längere Laufzeit von mehreren Stunden.</p>
<p>ich habe folgendes probiert.</p>
<pre><code class="language-cpp">GetLocalTime (&amp;st_start);
GetLocalTime (&amp;st_aktuell);

double dif=st_aktuell.wSecond-st_start.wSecond;

char *Laufzeit;
Laufzeit = new char[80];

char buffer2[20];
_itoa( dif, buffer2, 10 );
lstrcpy (Laufzeit, &quot;&quot;);
strcat( Laufzeit, buffer2 );

TextOut(hDC2,tabelle_x+325+200,tabelle_y+210,Laufzeit,strlen(Laufzeit));
</code></pre>
<p>soweit so gut (ich weiss, dass ich damit bisher nur die Zeitdifferenz der Sekunden berechne) jetzt geht es aber los ... ist die Sekundenzeit aktuell = 58<br />
und die Startzeit 34 hat man die gewollte differenz von 24 Sekunden.</p>
<p>Springt aber die aktuelle zeit um auf 1 dann ist die aktuelle Zeit als die Startzeit und ich bekomme als Sekundenwert -33 ... das darf natürlich so nicht sein.</p>
<p>Wie kann ich das verhindern?<br />
MISCHU</p>
]]></description><link>https://www.c-plusplus.net/forum/post/474476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/474476</guid><dc:creator><![CDATA[MISCHU]]></dc:creator><pubDate>Sat, 06 Mar 2004 14:56:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitdifferenz mit wSecond on Sat, 06 Mar 2004 15:25:03 GMT]]></title><description><![CDATA[<p>Wie das geht, steht in der Hilfe der <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemtime_str.asp?frame=true" rel="nofollow">SYSTEMTIME</a>-Struktur:</p>
<p>MSDN schrieb:</p>
<blockquote>
<p><strong>Remarks</strong><br />
It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should</p>
<ul>
<li>Convert the SYSTEMTIME structure to a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/filetime_str.asp?frame=true" rel="nofollow">FILETIME</a> structure.</li>
<li>Copy the resulting FILETIME structure to a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/ularge_integer_str.asp?frame=truehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/ularge_integer_str.asp?frame=true" rel="nofollow">ULARGE_INTEGER</a> structure.</li>
<li>Use normal 64-bit arithmetic on the ULARGE_INTEGER value</li>
</ul>
</blockquote>
<p>Damit kannst Du Dir dann was basteln:</p>
<pre><code class="language-cpp">UINT_PTR DiffFileTime(const FILETIME* pft1, const FILETIME* pft2) 
{ 
  ULARGE_INTEGER li1, li2;

    li1.QuadPart = reinterpret_cast&lt;const ULARGE_INTEGER*&gt;(pft1)-&gt;QuadPart / 10000000; 
    li2.QuadPart = reinterpret_cast&lt;const ULARGE_INTEGER*&gt;(pft2)-&gt;QuadPart / 10000000; 

  return(abs(static_cast&lt;int&gt;(li1.QuadPart - li2.QuadPart)));
} 

UINT_PTR DiffSystemTime(const SYSTEMTIME* pst1, const SYSTEMTIME* pst2) 
{ 
  FILETIME ft1, ft2; 

    SystemTimeToFileTime(pst1, &amp;ft1); 
    SystemTimeToFileTime(pst2, &amp;ft2); 

  return(DiffFileTime(&amp;ft1, &amp;ft2)); 
}
</code></pre>
<p>Beide Funktionen ermitteln die Differenz in Sekunden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/474489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/474489</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Sat, 06 Mar 2004 15:25:03 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitdifferenz mit wSecond on Sat, 06 Mar 2004 16:39:37 GMT]]></title><description><![CDATA[<p>Danke für deine Hilfe ... aber dein Code hat bei mir irgendwie nen paar Fehler erzeugt ... doch über den Tipp der MSDN hat's dann doch geklappt.</p>
<pre><code class="language-cpp">FILETIME fileTime1; 
            ULARGE_INTEGER uLargeIntegerTime1; 

            FILETIME fileTime2; 
            ULARGE_INTEGER uLargeIntegerTime2; 

            LARGE_INTEGER uLargeIntegerTimeRESULT; 
            FILETIME fileTimeRESULT; 
            SYSTEMTIME systemTimeRESULT;   

      result = SystemTimeToFileTime(&amp;st_start, &amp;fileTime1); 
      result = SystemTimeToFileTime(&amp;st_aktuell, &amp;fileTime2); 

      uLargeIntegerTime1.LowPart        =   fileTime1.dwLowDateTime; 
      uLargeIntegerTime1.HighPart       =   fileTime1.dwHighDateTime; 
      uLargeIntegerTime2.LowPart        =   fileTime2.dwLowDateTime; 
      uLargeIntegerTime2.HighPart       =   fileTime2.dwHighDateTime; 

      uLargeIntegerTimeRESULT.HighPart  =   uLargeIntegerTime2.HighPart - uLargeIntegerTime1.HighPart; 
      uLargeIntegerTimeRESULT.LowPart   =   uLargeIntegerTime2.LowPart  - uLargeIntegerTime1.LowPart; 

      fileTimeRESULT.dwLowDateTime      =   uLargeIntegerTimeRESULT.LowPart; 
      fileTimeRESULT.dwHighDateTime     =   uLargeIntegerTimeRESULT.HighPart; 

      // Zahl der Millisekunden seit dem 1.1.1601 
      result = FileTimeToSystemTime( &amp;fileTimeRESULT, &amp;systemTimeRESULT); 

		GetTimeFormat (LOCALE_USER_DEFAULT, LOCALE_USE_CP_ACP, &amp;systemTimeRESULT, NULL,
		uhrzeit_laufzeit, NUM_ELEMENTS(uhrzeit_laufzeit));

		TextOut(hDC2,tabelle_x+325+200,tabelle_y+210,uhrzeit_laufzeit,strlen(uhrzeit_laufzeit));
</code></pre>
<p>Falls es mal jemand braucht.<br />
ALSO TROTZDEM DANKE</p>
<p>MISCHU</p>
]]></description><link>https://www.c-plusplus.net/forum/post/474534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/474534</guid><dc:creator><![CDATA[MISCHu]]></dc:creator><pubDate>Sat, 06 Mar 2004 16:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitdifferenz mit wSecond on Sat, 06 Mar 2004 16:42:34 GMT]]></title><description><![CDATA[<p>MISCHu schrieb:</p>
<blockquote>
<p>aber dein Code hat bei mir irgendwie nen paar Fehler erzeugt ...</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Welche?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/474535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/474535</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Sat, 06 Mar 2004 16:42:34 GMT</pubDate></item><item><title><![CDATA[Reply to Zeitdifferenz mit wSecond on Sat, 06 Mar 2004 17:06:47 GMT]]></title><description><![CDATA[<p>Kann ich leider nicht rekonstruieren (Goldfischgedächtnis =&gt; es hält alle Infos nicht länger las 3 sek.)</p>
<p>Deshalb unterstelle ich einfach mal, dass der Fehler auf meiner Seite (bei der Implementierung) liegt.</p>
<p>THX<br />
MISCHU</p>
]]></description><link>https://www.c-plusplus.net/forum/post/474553</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/474553</guid><dc:creator><![CDATA[MISCHU]]></dc:creator><pubDate>Sat, 06 Mar 2004 17:06:47 GMT</pubDate></item></channel></rss>