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

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!camex!lloyd!kent
  3. From: kent@lloyd.Camex.COM (Kent Borg)
  4. Subject: Re: Detecting reboot or startup
  5. Message-ID: <1992Dec17.181910.12542@lloyd.Camex.COM>
  6. Organization: Camex Inc., Boston MA
  7. References: <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu> <1992Dec16.132825.13170@kth.se>
  8. Date: Thu, 17 Dec 1992 18:19:10 EST
  9. Lines: 33
  10.  
  11. In article <1992Dec16.132825.13170@kth.se> d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
  12. >In <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu> cmcclary@ucs.indiana.edu (Charles McClary) writes:
  13. >
  14. >>What is the best/preferred method for an application to detect if the
  15. >>system has been rebooted or restarted since it (the application) last ran.
  16. >
  17. >Install a gestalt selector with your own signature as selector code.
  18. >
  19. >If it's there, the application run previously during this "session."
  20. >The selector code should reside in the system heap, and could simply
  21. >return a 0 as result; you would test for presence, not return code.
  22.  
  23. I expected Jon to post that answer.  He is right, do it that way.
  24. However, if you want to run on old systems which don't have Gestalt,
  25. there is another (related) approach.
  26.  
  27. Put a little something else in the System heap, note its location in a
  28. file, and check whether it is still there when you next launch.
  29. (Rather than using a file to record the address you might walk the
  30. heap to find it.  I doubt Apple will change the heap structure in
  31. *old* systems.)
  32.  
  33. Off the top of my head, I can't remember how an app can allocate a
  34. handle in the System heap and also prevent Multifinder from cleaning
  35. up and deleting it for you when you exit, but loading a resource into
  36. the System heap and then detaching it should work.  Shouldn't it?
  37.  
  38.  
  39. --
  40. Kent Borg            kent@camex.com or kentborg@aol.com (when it is *working*)
  41.                                             H:(617) 776-6899  W:(617) 426-3577
  42. As always, things look better when some costs are left out.
  43.                               -Economist 3-28-92 p. 94
  44.