if you're distributing for Leopard only, use this:
-=-=-=-=-=-=-=-

@interface Preferences (PrivateMethods)


- (void)enableLoginItemWithLoginItemsReference:(LSSharedFileListRef
)theLoginItemsRefs
ForPath:(CFURLRef)thePath;

- (void)disableLoginItemWithLoginItemsReference:(LSSharedFileListRef
)theLoginItemsRefs
ForPath:(CFURLRef)thePath;


@end


@implementation Preferences (PrivateMethods)


- (void)enableLoginItemWithLoginItemsReference:(LSSharedFileListRef
)theLoginItemsRefs
ForPath:(CFURLRef)thePath

{

LSSharedFileListItemRef item = LSSharedFileListInsertItemURL
(theLoginItemsRefs, kLSSharedFileListItemLast, NULL, NULL, thePath, NULL,
NULL);

if (item)

{

CFRelease(item);

}

}


- (void)disableLoginItemWithLoginItemsReference:(LSSharedFileListRef
)theLoginItemsRefs
ForPath:(CFURLRef)thePath

{

UInt32 seedValue;

NSArray  *loginItemsArray = (NSArray
*)LSSharedFileListCopySnapshot(theLoginItemsRefs,
&seedValue);

for (id item in loginItemsArray)

{

LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)item;

if (LSSharedFileListItemResolve(itemRef, 0, (CFURLRef*) &thePath, NULL) ==
noErr)

{

if ([[(NSURL *)thePath path] hasPrefix:DeskguiseApplicationPath])

LSSharedFileListItemRemove(theLoginItemsRefs, itemRef);

}

}

[loginItemsArray release];

}


@end
-=-=-=-=-=-=-=-=-



On Mon, Jun 8, 2009 at 7:15 PM, Martin Batholdy <[email protected]>wrote:

> Hi,
>
> I have the following AppleScript that let me add an application to the
> "launch on startup" menu:
>
> tell application "System Events"
>        make login item at end with properties {path:"...",
> kind:application}
>        end tell
>
> The script works fine when I start it in the script editor for
> AppleScripts.
>
> But when I implement it in my cocoa app, the code is executed properly
> (when I copy the code that is created out of the log window and start it in
> the script editor it works) - but the app don't appear in the "launch on
> startup" menu under preferences -> users ...
>
> Does my app have the propper rights to do that?
> Is that the problem?
>
>
>
> thanks for any help!
>
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/chunk1978%40gmail.com
>
> This email sent to [email protected]
>
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to