Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
hi all,

i am working in carbon c application(Mac OS 10.4.7).

give one example for LSOpenApplication().

How to use FSRef() in LSOpenApplication()?

Thanks in advance
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
FSRefs are Carbon's way of working with files. You need to create one first with a known path (which should point to a .app):

Code:
OSStatus status = noErr;
FSRef ref;

status = FSPathMakeRef((const UInt8 *)path, &ref, NULL);
if (status != noErr) {
    printf("Couldn't get FSRef\n");
    return status;
}

Then once you have the FSRef setup you can call LSOpenApplication:

Code:
LSApplicationParameters params = {0, kLSLaunchDefaults, &ref, NULL, NULL, NULL};
return LSOpenApplication(&params, NULL);
 

chidambaram

macrumors member
Original poster
Mar 9, 2008
67
0
thanks for ur reply sir.

its not working for me

what to give in the path variable. I given the entire address directly

i tried as

OSStatus status = noErr;
FSRef ref;

const char path[] = "/Users/laserwords/Desktop/one.indd";

status = FSPathMakeRef((const UInt8 *)path, &ref, NULL);

LSApplicationParameters params = {0, kLSLaunchDefaults, &ref, NULL, NULL, NULL};

LSOpenApplication(&params, NULL);

what error i made here?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I'm pretty sure it only works with .app applications (which are bundles). It's like opening something in Finder. You can't double-click an executable in the Finder and launch it, you have to do it via the command line.

So if one.indd is just a plain executable you need to use another method to launch it. There might be Carbon ways of doing it, but you could probably just use standard POSIX functions for that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.