home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!camex!lloyd!kent
- From: kent@lloyd.Camex.COM (Kent Borg)
- Subject: Re: Detecting reboot or startup
- Message-ID: <1992Dec17.181910.12542@lloyd.Camex.COM>
- Organization: Camex Inc., Boston MA
- References: <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu> <1992Dec16.132825.13170@kth.se>
- Date: Thu, 17 Dec 1992 18:19:10 EST
- Lines: 33
-
- In article <1992Dec16.132825.13170@kth.se> d88-jwa@dront.nada.kth.se (Jon Wtte) writes:
- >In <cmcclary-151292113831@mcclary-mac.ucs.indiana.edu> cmcclary@ucs.indiana.edu (Charles McClary) writes:
- >
- >>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.
- >
- >Install a gestalt selector with your own signature as selector code.
- >
- >If it's there, the application run previously during this "session."
- >The selector code should reside in the system heap, and could simply
- >return a 0 as result; you would test for presence, not return code.
-
- I expected Jon to post that answer. He is right, do it that way.
- However, if you want to run on old systems which don't have Gestalt,
- there is another (related) approach.
-
- Put a little something else in the System heap, note its location in a
- file, and check whether it is still there when you next launch.
- (Rather than using a file to record the address you might walk the
- heap to find it. I doubt Apple will change the heap structure in
- *old* systems.)
-
- Off the top of my head, I can't remember how an app can allocate a
- handle in the System heap and also prevent Multifinder from cleaning
- up and deleting it for you when you exit, but loading a resource into
- the System heap and then detaching it should work. Shouldn't it?
-
-
- --
- Kent Borg kent@camex.com or kentborg@aol.com (when it is *working*)
- H:(617) 776-6899 W:(617) 426-3577
- As always, things look better when some costs are left out.
- -Economist 3-28-92 p. 94
-