[comp.sys.mac.programmer] Startup Applications?

siegel@endor.harvard.edu (Rich Siegel) (04/13/89)

Is there a way to determine whether your program is running as a startup
application? I suspect it can be done, since PowerStation knows when to
run its startup page and when to run its user interface...

R.

~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

 "She told me to make myself comfortable, so I pulled down my pants
 and sat in the pudding." -Emo Phillips
~~~~~~~~~~~~~~~

brecher@well.UUCP (Steve Brecher) (04/17/89)

In article <1623@husc6.harvard.edu> siegel@endor.harvard.edu (Rich Siegel)
writes:

> Is there a way to determine whether your program is running as a startup
> application? I suspect it can be done, since PowerStation knows when to run
> its startup page and when to run its user interface...

PowerStation does this when it is launched:

    IamStartup := false
    Scan system heap for PowerStation's owned relocatable block
    if not found then
        create the owned block
        if startup name in boot blocks of system volume = (CurApName) then
            IamStartup := true

This is not entirely foolproof, as the user might have switch-launched to a
new system volume for which PowerStation is the startup in the boot blocks,
from the real startup volume which did not have PowerStation as the startup
application.  But I can't think of any foolproof method.
-- 

brecher@well.UUCP (Steve Brecher)

MAC.ROMOS@applelink.apple.com (Ian Hendry) (04/20/89)

>Is there a way to determine whether your program is running as a startup
>application? I suspect it can be done, since PowerStation knows when to
>run its startup page and when to run its user interface...

Boy what a bad Idea.....
That said, I know of one bug that will help in some circumstances:
LoMem global $210 is the BootDrive.  This is the same as the System folder 
(as returned by SysEnvirns) except when you are the startup App in which 
case it is the App dir.  This is not a really good solution since if your 
app happens to be in the system folder it will fail.  

I take it that you are concerned not only with whether you are the 
startup, but whether you are actually running as the startup app THIS 
time(ie you could be the startup and quit and re-run not as the startup).  
If this is not the case then you could look at the startup file or the 
boot blocks or whatever.  This is probably dangerous, but I really don't 
know that much about it.
Maybe some of the managers are not initialized...doubt you could count on 
that because INITs may do any of these initializations.

Just curious, why do you want to know?

PS:  By the way this is an area about which I do not know much... so I 
make no guarantees about this particular post or its correctness.  

Ian Hendry
MAC.ROMOS@applelink.apple.com
Make sure my name is in the subject of any Email, or post replies to 
network.
TE: 408-974-4737

Disclaimer:  It was all HIS idea anyway!  Nothing I say reflects anything 
my employer means... or anything I mean for that matter.