Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Starting as Startup Item?



I don't know the reason you need to know the difference between starting up as a login or not, but be careful, because this solution will only "mostly" work.

Scenario: User adds application to Startup Items then launches your Application from Finder.

You will be listed in the startup items, but you didn't start at Startup.

Depending on the original need, this solution may be "good enough", but as always, it is good to know of potential cases where it may fail so that you can deal with it appropriately.

Mark Munz

On Dec 5, 2004, at 12:03 AM, Darkshadow wrote:

You can check the loginwindow.plist file, and see if your application is listed there. This code should do it. Note that the autolaunched applications could be moved in the future to some other plist, or even not saved (like this) at all, but it has been in the loginwindow.plist file since 10.1 (I'm not sure about 10.0; I never looked back then). Keep that in mind if you decide to use this. Also, I think the keys had different names in 10.1, so if you're looking for compatibility with 10.1, you may want to check that out.

- (BOOL)isInAutoLaunchDictionary
{
NSString *loginwindowPlist=[@"~/Library/Preferences/loginwindow.plist" stringByExpandingTildeInPath];
NSDictionary *autoLaunchedApps=[NSDictionary dictionaryWithContentsOfFile:loginwindowPlist];
NSArray *appsArray=[autoLaunchedApps objectForKey:@"AutoLaunchedApplicationDictionary"];
NSEnumerator *anEnum=[appsArray objectEnumerator];
id anObject;


while ((anObject=[anEnum nextObject])) {
if ([[[NSBundle mainBundle]bundlePath] isEqualToString:[anObject objectForKey:@"Path"]]) {
return YES;
}
}


	return NO;
}

Darkshadow (aka Mike Nickerson)

On Dec 4, 2004, at 3:20 AM, Mihkel Tammepuuu wrote:

How can an application determine if it was launched as a Startup Item on logging in to Mac OS or a usual way like (double)clicking it's icon?

//
Mihkel Tammepyy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/ email@hidden


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Starting as Startup Item? (From: Mihkel Tammepuuu <email@hidden>)
 >Re: Starting as Startup Item? (From: Darkshadow <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.