Re: launching 2 same applications
Re: launching 2 same applications
- Subject: Re: launching 2 same applications
- From: "Sean Liong" <email@hidden>
- Date: Thu, 23 Oct 2003 04:39:40 +0000
Can I conclude that no 2 same applications from different paths will be able
to run at the same time as it will quit together eventually?
Best regards,
sean
From: "Sean Liong" <email@hidden>
To: email@hidden
CC: email@hidden, email@hidden
Subject: Re: launching 2 same applications
Date: Fri, 17 Oct 2003 14:07:54 +0000
Hi,
you wrote...
//But if all you want to do is launch one application and quit the one
that launched it, launchApplication is //the one you want.
From the previous mail, you have suggested using NSWorkspace,
launchApplication.
Yes, the application did launch but also quit together after returning
false.
Yes this is what in the main();
...
myPath = [[NSBundle mainBundle] bundlePath];
if(! [myPath isEqualToString:@"Users/MyComputer/NotInCorrectPath/xx.app"] )
{
[[NSWorkspace sharedWorkspace]
launchApplication:@"/Users/MyComputer/InCorrectPath/xx.app"];
return false;
}
return NSApplicationMain(argc, argv);
}
The new application launch appeared bouncing in the dock, but by choosing
"Show in Finder", it showed that actually the xx.app from the
NotInCorrectPath "launched"... and will then eventually quit after
returning false from the above code.
Any ideas what might have went wrong here?
Thanks & regards,
Sean
From: "M. Uli Kusterer" <email@hidden>
To: "Sean Liong" <email@hidden>, email@hidden,
email@hidden
Subject: Re: launching 2 same applications
Date: Wed, 8 Oct 2003 20:38:19 +0200
At 18:00 Uhr +0000 08.10.2003, Sean Liong wrote:
I am writing an application for a usb mass storage flash storage device.
The application cannot be launch on the usb device itself where some of
the functions won't allow. So I need to ensure that the application will
only run on a specific path and not on the device itself.
so any suggestion?
Okay, that's something entirely different than ensuring your app is
always in the Applications folder. The only thing you want to do is find
out whether your application is residing on the device it is currently
controlling. Am I understanding this correctly?
Well, in that case, [[NSBundle mainBundle] bundlePath] will, as already
said, give you the path to your bundle. From there on, you'll have to find
out what device this path is on. This depends on your USB mass storage
device. If this application works with this device, I suppose you have
some sort of path to the device, or a driver name, or something like that?
If you had a path to the root level of the device (like
/Volumes/MyUSBDevice/), you could simply do a string compare on the two
paths, and voila, you'd know whether the file's on the device.
Otherwise, you'd probably have to mess with some Unix (BSD? POSIX?) API,
or talk to the driver directly. That's not really my area of expertise,
but I'm sure that there's some Darwin newsgroup or mailing list where you
can find out about these Unix APIs if no Unix guru here can help you.
Once you have done that, you know whether the copy of the app being
launched is on the USB device, you can react by putting up a dialog and
telling the user. If you want to be so polite as to offer the user the
option of opening a copy of your app that already resides on the hard
disk, you could use LaunchServices to locate your application
(LSFindApplicationForInfo in CoreServices.framework). NSWorkspace
apparently only looks in "the standard locations" (I guess that means
/Applications and ~/Applications), but LSFindApplicationForInfo should do
the trick nicely if you use the bundle identifier to look up the app.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
Download the latest MSN Messenger http://messenger.msn.com.my
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_________________________________________________________________
Download the latest MSN Messenger
http://messenger.msn.com.my
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.