home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!elroy.jpl.nasa.gov!lambda.msfc.nasa.gov!NewsWatcher!user
- From: steve.herman%express@freedom.msfc.nasa.gov (Steve Herman)
- Subject: Re: Detecting reboot or startup
- Message-ID: <steve.herman-161292132205@128.158.4.199>
- Followup-To: comp.sys.mac.programmer
- Sender: news@lambda.msfc.nasa.gov (Newsmaster)
- Nntp-Posting-Host: hermasj.msfc.nasa.gov
- Organization: BCSS
- References: <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu>
- Date: Wed, 16 Dec 1992 19:44:51 GMT
- Lines: 35
-
- In article <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu>,
- cmcclary@ucs.indiana.edu (Charles McClary) wrote:
- >
- > What is the best/preferred method for an application to detect if the
- > system has been rebooted or restarted since it (the application) last ran.
- >
-
- At one time I had attempted to do this by doing the following:
-
- 1. Get the current time in seconds using GetDateTime()
- 2. Get number of ticks since last startup using TickCount()
- 3. Divide #2 by 60 to get seconds since startup.
- 4. Subtract #3 from #1 to get time in seconds of startup
- 5. Save this value to a file.
- 6. Whenever my application would startup it would perform steps 1-4 and
- compare to the value stored in the file. If the values matched, plus or
- minus a fudge factor I built in, then I would assume the machine had not
- been re-booted since I last ran.
-
- However, this would obviously break if the user changed the date/time on
- his Mac. I also found out that TickCount is incremented during the
- vertical retrace interrupt and whenever this interupt is disabled the ticks
- are not incremented so it gradually loses time. On my particular machine it
- was losing almost a minute for each hour my machine was up. This was going
- to make my built-in fudge factor unrealistic.
-
- I attempted to find another way to do this but eventually gave up. I
- would like to know if you discover a reliable method.
-
-
- ----------------------------------------------------
- - Steve Herman - BCSS
- - Boeing Computer Support Services
- - Huntsville, AL
- ----------------------------------------------------
-