Re: Termination Running Applications ...
Re: Termination Running Applications ...
- Subject: Re: Termination Running Applications ...
- From: has <email@hidden>
- Date: Wed, 18 Mar 2009 19:39:17 +0000
Mic Pringle wrote:
Is it possible to terminate other running applications (not my own)
from within my application ?
OSStatus QuitApplicationProcessWithPID(pid_t pid) {
AppleEvent evt, res;
AEDesc errDesc;
OSStatus err;
// build and send a 'quit' event
err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication,
typeKernelProcessID,
&pid, sizeof(pid),
kAutoGenerateReturnID,
kAnyTransactionID,
&evt, NULL, "");
if (err) return err;
err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
AEDisposeDesc(&evt);
// note: process may quit without replying
if (err == connectionInvalid) return noErr;
if (err) return err;
// check if reply event contains an error number, e.g.
userCanceledErr
err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &errDesc);
if (err == noErr) {
AEGetDescData(&errDesc, &err, sizeof(err));
AEDisposeDesc(&res);
} else if (err == errAEDescNotFound)
err = noErr;
return err;
}
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden