Skip navigation.
 
mlRe: Default Web Browser
FROM : Steve Dekorte
DATE : Sun Jan 26 23:39:06 2003

On Sunday, January 26, 2003, at 10:59 PM, Steve Dekorte wrote:
> Vince DeMarco wrote:

>> Steve Dekorte wrote:

>>> How can I programmatically find which web browser is set to be the 
>>> default in the System/Internet preferences?

>> look up the function LSGetApplicationForURL()

> Thanks for the response. Should this code work?:


Found the problem - the file has to be present. This works:

  {
    char *URL = 
"file:///System/Library/Frameworks/AppKit.framework/Versions/C/
Resources/English.lproj/Documentation/Reference/ObjC_classic/
AppKitTOC.html";
    FSRef appRef;
    CFURLRef appURL;

    CFStringRef urlStr = CFStringCreateWithCString(NULL, URL, 
kCFStringEncodingASCII);
    CFURLRef inURL = CFURLCreateWithString(NULL, urlStr, NULL);

    OSStatus oss = LSGetApplicationForURL(inURL, kLSRolesEditor, 
&appRef, &appURL);
    CFStringRef s = CFURLGetString(appURL);
    printf("default web browser = %s\n", [[(NSString *)s 
lastPathComponent] cString]);
  }

Cheers,
Steve
OSX freeware and shareware: http://www.dekorte.com/downloads.html


Related mailsAuthorDate
mlDefault Web Browser Steve Dekorte Jan 26, 21:28
mlRe: Default Web Browser Vince DeMarco Jan 26, 22:11
mlRe: Default Web Browser Steve Dekorte Jan 26, 23:03
mlRe: Default Web Browser Steve Dekorte Jan 26, 23:39
mlRe: Default Web Browser Steve Dekorte Jan 27, 00:00
mlRe: Default Web Browser Nick Zitzmann Jan 27, 04:08
mlRe: Default Web Browser Vince DeMarco Jan 27, 08:26
mlRe: Default Web Browser Jérôme Seydoux Feb 3, 06:00