• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get default Browser and Mail Client
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get default Browser and Mail Client


  • Subject: Re: Get default Browser and Mail Client
  • From: Nicholas Riley <email@hidden>
  • Date: Mon, 16 Sep 2002 23:04:11 -0500
  • Mail-followup-to: Stephane ODUL <email@hidden>, email@hidden

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.

  • Follow-Ups:
    • Re: Get default Browser and Mail Client
      • From: Stephane ODUL <email@hidden>
References: 
 >Re: Get default Browser and Mail Client (From: Nathan Day <email@hidden>)
 >Re: Get default Browser and Mail Client (From: Stephane ODUL <email@hidden>)

  • Prev by Date: Re: Obj-C question: protocol usage and inheritance
  • Next by Date: Re: Obj-C question: protocol usage and inheritance
  • Previous by thread: Re: Get default Browser and Mail Client
  • Next by thread: Re: Get default Browser and Mail Client
  • Index(es):
    • Date
    • Thread