LSGetApplicationForURL() failed

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.quickheal.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 am waiting for some quick replies which i had not got last time.

Thanks in advance,

Dhiraj

Mac mini, Mac OS X (10.6.4)

Posted on Apr 19, 2013 2:38 AM

Reply
7 replies

Apr 19, 2013 3:51 AM in response to Dhiraj Bhor

Dhiraj Bhor wrote:


Hi,

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

I have code as below

.....

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 am waiting for some quick replies which i had not got last time.

Thanks in advance,

Dhiraj

A simple Google search which you can do yourself will give you the answer.

Apr 19, 2013 7:01 AM in response to msuper69

I dont know whether i searched wrongly or what but i need simplest answer.If you have taken a look at this question can you provide me some input about how to go ahead with such an error(runtime).

Thanks once again for advice but when i put my question on Apple Developer Forum for help

i think expertise provide best way to do that task.It will increase reusability of thoughts.What would you say?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

LSGetApplicationForURL() failed

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.