LSGetApplicationForURL() failed Error -10814

  • Hi,

    I am developing an application tool that requires a function which will
    give me users default browser name.

    I have code as below

        FSRef appRef;

        CFURLRef inUrl;

        OSStatus status;

        CFStringRef urlString;

        CFURLRef appUrlRef;

        CFStringRef defBrowserName;

        cfURLStr = CFStringCreateWithCString(kCFAllocatorDefault,"http://
    www.apple.com", kCFStringEncodingUTF8);

        if (NULL == urlString)                                exit(-1);

      inUrl = CFURLCreateWithString(NULL, urlString, NULL);

        status = LSGetApplicationForURL(inUrl, kLSRolesEditor, &appRef,
    &appUrlRef);

        if (noErr != status)    {  CFRelease(inUrl);          CFRelease
    (urlString); exit(-1);  }

        defBrowserName = CFURLCopyLastPathComponent(inUrl);

    NSLog(@"Here is Default Browser Name %@", (NSString *)defBrowserName);

    This code works well when i am normal user. But when i ran same code as
    super user, it give me error

    that

    *LSGetApplicationForURL() failed. Error:(-10814)*

    Why this happened?

    I read about Launch Services Database.

    Now i am seeking for a solution to get default browser name.

    Is there no other way to get default browser name?

    If any other way provide me some help.

    Suggestions are welcome.

    Thanks in advance,

    Dhiraj
  • On Apr 27, 2013, at 2:39 AM, Dhiraj Bhor <dhirajbhor21...> wrote:

    > This code works well when i am normal user. But when i ran same code as
    > super user, it give me error
    >
    > that
    >
    >
    > *LSGetApplicationForURL() failed. Error:(-10814)*
    >
    >
    >
    > Why this happened?

    The documentation for LSGetApplicationForURL() says: "If no application suitable for opening the item is found in the Launch Services database, the function will return the result code kLSApplicationNotFoundErr."

    kLSApplicationNotFoundError is error -10814.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On 2013 Apr 27, at 01:39, Dhiraj Bhor <dhirajbhor21...> wrote:

    > I am developing an application tool that requires a function which will
    > give me users default browser name.

    See the two methods…

    +defaultBrowserBundleIdentifier
    +defaultBrowserDisplayName

    in here

    https://github.com/jerrykrinock/ClassesObjC/blob/master/SSWebBrowsing.m

    Pretty old but I can't remember ever having any trouble with them.
previous month april 2013 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Go to today