Re: Accessing System Preferences?
Re: Accessing System Preferences?
- Subject: Re: Accessing System Preferences?
- From: Creed Erickson <email@hidden>
- Date: Sun, 10 Aug 2003 17:29:19 -0700
On Sunday, August 10, 2003, at 02:50 PM, Nick Morris wrote:
>
Hi,
>
>
I am having a real mental block on this one and after 48 hours of
>
searching and thinking I still do not have an answer to a really
>
simple question!
>
>
The question: How do I retrieve the System Preference setting for
>
Mail and Web for a user?
>
>
Basically, it is just so the right Applescript fires in my application
>
for the right mail program or web-broswer.
>
>
Thanks for your time and help!
>
>
This is in the archives at
http://cocoa.mamasam.com/COCOADEV/2002/09/2/45230.php
Here's the answer provided by Nicholas Riley:
>
Please read about LaunchServices, it explains all this. How to
>
extract application info such as the pretty name? You can use
>
LSCopyDisplayNameForRef, or CF/NSBundle, depending on what you want.
>
>
Get the preferred Web browser? Use a URL scheme like 'http' with
>
LSGetApplicationForURL, not a mapping for 'html' or 'webloc'. Just
>
browsing through LaunchServices.h should give you a pretty good idea.
>
>
For example, here's a cleaner way of getting the preferred mail/Web
>
protocol handler:
>
>
#import <Foundation/Foundation.h>
>
#import <ApplicationServices/ApplicationServices.h>
>
>
int main (int argc, const char * argv[]) {
>
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>
NSURL *appURL = nil;
>
OSStatus err;
>
>
err = LSGetApplicationForURL((CFURLRef)[NSURL URLWithString:
>
@"mailto:"];
>
// or "http:"
>
kLSRolesAll, NULL, (CFURLRef
>
*)&appURL);
>
if (err != noErr) NSLog(@"error %ld", err);
>
else NSLog(@"%@", appURL);
>
[pool release];
>
return 0;
>
}
>
>
This successfully identified Navigator and Eudora for me. Internet
>
Config provides a much nicer (IMO) API, but it has not been properly
>
modernized, is deprecated and Apple provides no way to edit its
>
settings in OS X...
>
---
Creed Erickson <email@hidden>
"Not a shred of evidence exists in favor of the idea that life is
serious."
- Brendan Gill
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.