Skip navigation.
 
mlRe: Quitting one application from within another
FROM : John Stiles
DATE : Thu Dec 16 17:43:08 2004

On Dec 16, 2004, at 8:26 AM, j o a r wrote:
>
> On 2004-12-16, at 17.15, Peter Browne wrote:
>

>> Hi, I'm wondering if it's possible to terminate an application from 
>> within another. I know you can launch applications etc by using the 
>> NSSharedWorkspace methods, but I haven't come across anything similar 
>> for terminating that application when it's no-longer needed. Any 
>> ideas?

>
> There is no convenience functionality in Cocoa for doing that. You 
> could investigate sending a quit AppleEvent (see list archives for 
> more info), or if you need to force quit, use NSTask and "kill".
>
> It's also quite possible there's something available to do this in 
> Carbon or some other library / framework that I don't know of.


Sending a quit AppleEvent would be the Carbon way (and AFAIK the only 
way :)  ). AEBuildAppleEvent is what you want.
The syntax can be pretty puzzling if you don't know AppleEvents; you 
can ask George Warner (<email_removed>) for details if you get stuck. 
He knows AppleScript pretty darn well.
http://developer.apple.com/documentation/Carbon/Reference/
Apple_Event_Manager/index.html

Related mailsAuthorDate
mlQuitting one application from within another Peter Browne Dec 16, 17:15
mlRe: Quitting one application from within another j o a r Dec 16, 17:26
mlRe: Quitting one application from within another John Stiles Dec 16, 17:43
mlRe: Quitting one application from within another Bill Cheeseman Dec 16, 21:45