Article View: borland.public.cppbuilder.nativeapi
Article #16228Re: Get the system uptime?
From: Hans Galema
Date: Wed, 28 May 2003 07:57
Date: Wed, 28 May 2003 07:57
39 lines
2126 bytes
2126 bytes
vERUs wrote:
> Hi, I wonder how I can obtain the system uptime?
> Can this be made using "NtQuerySystemInformation"?
Don't know.
> It's for a monitoring
> tool that expects to be running for long periods of time so I can't use
> TickCount() because of it's ~47 days limit.
GetTickCount () ?
Why not ? One can monitor a system without knowing the time.
You could determine the date-time at startup and compare that
with the actual date-time. Just substract two values.
(Only if the tool starts at boot)
Also you can keep track of GetTickCount() passing the maximum
value and starting with zero again. (Also assuming your tool
runs as long as the OS runs).
__int64 GetTotalTickCount ( void )
{
static __int64 former_tickcount = 0;
static unsigned int lasttickcount = 0;
unsigned int tickcount = GetTickCount();
if ( tickcount < lasttickcount )
former_tickcount += 0xFFFFFFFF;
lasttickcount = tickcount;
return former_tickcount + tickcount;
}
Hans.
Technical Details
Message-ID:
<3ed46bf8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ed3dfa5$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7346dca14e776e6d X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-28 01:05:13 PST Date: Wed, 28 May 2003 09:57:54 +0200 From: Hans Galema <j.m.galema.dontusethis@maartens.nl> User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Get the system uptime? References: <3ed3dfa5$1@newsgroups.borland.com> In-Reply-To: <3ed3dfa5$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.108.11 Message-ID: <3ed46bf8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054108664 129.125.108.11 (28 May 2003 00:57:44 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail