home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19921 < prev    next >
Encoding:
Text File  |  1992-12-16  |  2.0 KB  |  49 lines

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