Re: Get default Browser and Mail Client
Re: Get default Browser and Mail Client
- Subject: Re: Get default Browser and Mail Client
- From: Stephane ODUL <email@hidden>
- Date: Mon, 16 Sep 2002 22:13:39 -0700
Thanks a lot, this is exactly what I needed.
I use LSCopyDisplayNameForRef like you suggested (NSBundle just allows
me to get the bundle id, not what I'm looking for).
Stephane ODUL
On Monday, Sep 16, 2002, at 21:04 US/Pacific, Nicholas Riley wrote:
On Mon, Sep 16, 2002 at 08:02:48PM -0700, Stephane ODUL wrote:
By the way is there a cleaner way than regex to extract the name of
the app from the URL I get: I receive
/Applications/Internet/Navigator.app and I want "Navigator".
And thank you I'm half way to solve my problem now :-).
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...
--
=Nicholas Riley <email@hidden> |
<http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
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.
_______________________________________________
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.