Re: GetTickCount

From: Per Larsen (perATportablemindsDOTcom)
Date: 01/26/04


Date: Mon, 26 Jan 2004 11:35:21 +0100


<j.munk@XremoveXthisXmaccor.com> wrote in message
news:4014e4e5@newsgroups.borland.com...
> Hi,
>
> I have a couple of application with some timing based on the
"GetTickCount"
> API call. Since this function counts milliseconds since the PC was turned
on
> and is a DWord it will roll over every 49.7 days. I would like to check
this
> but rather than having my PC to run continously for 49.7 days, I wonder if
> there is anywhere where this number can be changed. I.e. so I can set it
> close and then see what happens with my programs when it rolls over.

Fake it.

I'm not aware of a way to do what you're asking for directly (though there
may be a way), but what I would do is write a shell routine and call that
instead. Something like this (off the top of my head):

{$IFDEF TestingTimerWrap}
var
  TickBias: DWord;
{$ENDIF}

function GetTickCount: DWord;
begin
  Result := Windows.GetTickCount;
{$IFDEF TestingTimerWrap}
  Result := (Result + TickBias) mod MAXDWORD;
{$ENDIF}
end;

...
{$IFDEF TestingTimerWrap}
initialization
  TickBias := MAXDWORD - Windows.GetTickCount - 10000; {or something}
{$ENDIF}
end.

IHTH

- Per



Relevant Pages

  • Re: COM thread deadlock problem
    ... Since S manages inputs from the browser (ASP session), ... > DWORD Win2KWaitForMultipleObjectsWithMessageLoop(DWORD nCount, CONST ... > DWORD dwTickBefore = GetTickCount(); ... > // get a tick snapshot after we call DispatchMessage ...
    (microsoft.public.win32.programmer.ole)
  • Re: Letzte reboot Zeit
    ... Energiesparmodus und Ruhezustand müssen dabei ignoriert werden. ... GetTickCount() liefert einen DWORD zurück, und ist dadurch auf knapp 50 ... Die Funktion sollte ab Windows 2000 lauffähig sein. ...
    (microsoft.public.de.vc)
  • RE: Get Milliseconds from COleDataTimeSpan
    ... DWORD t1 = GetTickCount(); ... "Thomas Schindler" wrote: ... > I want to retrieve the Milliseconds from COleDataTimeSpan. ...
    (microsoft.public.vc.mfc)
  • Re: GetTickCount Frage.
    ... DWORD m_dwLastEmpfangsBlock = GetTickCount() ... if- m_dwLastEmpfangsBlock> TIMEOUT) ... Wenn jetzt nach 49,x Tagen der Wert von GetTickCountnach 0 überläuft, passt ja meine Überwachung nicht mehr. ...
    (microsoft.public.de.vc)