Re: launching 2 same applications
Re: launching 2 same applications
- Subject: Re: launching 2 same applications
- From: "Sean Liong" <email@hidden>
- Date: Thu, 09 Oct 2003 22:07:19 +0000
Hi,
Thanks for the reply.
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.
So if saying that if I call a dialog when found that the application is not
running a desire path and ask the user that he should run the application
like for example /Application/xx.app. It is not that "straightFoward".
What is the main purpose of LaunchServices when compare to API in
NSWorkspace? I used NSTask for launching application. In the begining of the
application, I called NSTask to launch other different application and quit
(no problem). But I cannot quit the application itself if it is launching
the same program.
In windows, mfc program, I saw application just return false at the main
function (quit eventually) and there is no problem launching the same
program from another path
Can this be done?
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 ringtones, logos and picture messages from MSN Malaysia
http://www.msn.com.my/mobile/ringtones/default.asp
_______________________________________________
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.