开发者

How to quit an application programatically in macintosh

I need to quit an application from another application. I know how to open ano开发者_运维知识库ther application from my application but I don't know how to quit it.

To Open other app:

 CFURLRef mtURL = CFURLCreateWithString(kCFAllocatorDefault,CFSTR("TestApplication:"), NULL);
    LSOpenCFURLRef(mtURL,nil);

Can any one please suggest on this?

Thank you, Chandra.


Are you launching that app or is it already running?

If you are launching it yourself, instead of using your URL method, you could use a NSTask, that would give you more control on the exectution.

NSTask has a terminate message you can send.

See this page for some examples: http://www.cocoadev.com/index.pl?NSTask


Also see this SO question: How to terminate a process (not self) from inside a Cocoa application


According to the documentation, it doesn't look like this is supported; there is only one function to close the application, and that function is deprecated. Perhaps you could send your application a message that your application could interpret and kill itself of its own volition?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜