BOOL result = YES; Boolean converted = false; unsigned i = 0; pid_t pid = -1; NSBundle *glBundle = [ NSBundle mainBundle ]; NSDictionary *d = nil; NSDictionary *dd; NSString *z; NSString *zzz; NSMutableString *m; NSArray *arr; NSURL *urlRef = nil; NSError *inError = nil; FSRef exeRef; LSApplicationParameters inAppParams; ProcessSerialNumber outPSN; OSStatus err = noErr; memset( &inAppParams, 0, sizeof( inAppParams ) ); memset( &outPSN, 0, sizeof( outPSN ) ); if( glBundle ) { // Get main bundle info dict... d = [ glBundle infoDictionary ] if( d ) { // Get the GL bundle's path from the info dict... z = [ d objectForKey:kNSBundleInitialPathInfoDictKey ]; if( z ) { // Break the path up into a path component array... arr = [ z componentsSeparatedByString:kSlashStringKey ]; // Make a mutable path string to manipulate... m = [ NSMutableString stringWithCapacity:0 ]; } } } if( m & arr ) { for(i=0; i<[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@"/" ]; } //go up one level to get at Info.plist [m appendString:@"Info.plist" ]; dd = [ NSDictionary dictionaryWithContentsOfFile:m ]; zzz = [ dd valueForKey:@"CFBundleExecutable" ]; //reset [ m setString:@"" ]; //Loop again appening all path compoents to final file to launch... for(i=0; i<[ arr count] - 1; i++ ) { [m appendString:[arr objectAtIndex:i] ]; [m appendString:@"/" ]; } //now get full path to the file we want to actually run... [ m appendString:zzz ]; [ m appendString:@".ifn" ]; urlRef = [ NSURL fileURLWithPath:m ]; if( urlRef ) { CFShow( urlRef ); converted = CFURLGetFSRef( (CFURLRef)urlRef, &exeRef ); if( converted ) { // Setup launch param block... inAppParams.application = &exeRef; // Launch! err = LSOpenApplication( &inAppParams, &outPSN ); if( !err ) { err = GetProcessPID( &outPSN, &pid ); if( !err ) { lppiProcInfo->dwProcessId = (DWORD)pid; result = true; } } } }
________________________________ From: Michael Ash <michael....@gmail.com> To: cocoa-dev <cocoa-dev@lists.apple.com> Sent: Monday, April 27, 2009 9:57:33 PM Subject: Re: Why is NSString->FSRef so hard? On Tue, Apr 28, 2009 at 12:51 AM, Erg Consultant <erg_consult...@yahoo.com> wrote: > So why isn't it working? Why does LSOpenApplication give me an error? It is impossible to answer questions of this nature if you do not post your code. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/erg_consultant%40yahoo.com This email sent to erg_consult...@yahoo.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com