Terminating another application.

  • Hi All,

    I am trying to terminate another application by using my application.
    Eg:
    I have to kill another application that has relation with my component,
    Please tell me how is it possible.

    Can i use the same code

    [NSApp terminate:]

    How can i give another application's id.
    Please help me i may be wrong.

    Expecting a good solution from someone,

    --
    Regards,
    Anoop T Varghese
    Ph:919940358382
  • Rather than terminating the process, a better approach would probably
    be to signal that you want it to close as soon as possible.
    Distributed Objects or Distributed Notifications would do the job.

    Mike.

    On 18 Jan 2008, at 16:43, Anoop Thomas Varghese wrote:

    > Hi All,
    >
    > I am trying to terminate another application by using my application.
    > Eg:
    > I have to kill another application that has relation with my
    > component,
    > Please tell me how is it possible.
    >
    > Can i use the same code
    >
    > [NSApp terminate:]
    >
    > How can i give another application's id.
    > Please help me i may be wrong.
    >
    > Expecting a good solution from someone,
    >
    > --
    > Regards,
    > Anoop T Varghese
    > Ph:919940358382
  • Or use AppleScript/AppleEvents, which have a built-in "quit" message for
    any regular app. (But not for command-line utilities or badly-written
    Carbon apps)

    Mike Abdullah wrote:
    > Rather than terminating the process, a better approach would probably
    > be to signal that you want it to close as soon as possible.
    > Distributed Objects or Distributed Notifications would do the job.
    >
    > Mike.
    >
    > On 18 Jan 2008, at 16:43, Anoop Thomas Varghese wrote:
    >
    >> Hi All,
    >>
    >> I am trying to terminate another application by using my application.
    >> Eg:
    >> I have to kill another application that has relation with my component,
    >> Please tell me how is it possible.
    >>
    >> Can i use the same code
    >>
    >> [NSApp terminate:]
    >>
    >> How can i give another application's id.
    >> Please help me i may be wrong.
    >>
    >> Expecting a good solution from someone,
    >>
    >> --
    >> Regards,
    >> Anoop T Varghese
    >> Ph:919940358382

  • Il giorno 18/gen/08, alle ore 17:43, Anoop Thomas Varghese ha scritto:

    > Hi All,
    >
    > I am trying to terminate another application by using my application.
    > Eg:
    > I have to kill another application that has relation with my
    > component,
    > Please tell me how is it possible.
    >
    > Can i use the same code
    >
    > [NSApp terminate:]
    >
    > How can i give another application's id.

    If by "id" you mean the object pointer type "id" that Objective-C
    provides, you cannot; in the sense that another application's objects
    are not directly accessible, because they are in another app's address
    space.

    If you control the code for the other application, you can use
    Distributed Objects, distributed notifications or other interprocess
    communication techniques to send a message to it asking to quit. If
    you don't, all Mac apps respond to the "quit" Apple Event; you can
    write a small "tell app "Some Application" to quit" AppleScript to
    send that event, and NSAppleScript to run it from your Cocoa app.

    Google any of the terms above for more info.

      - ∞
  • John Stiles wrote:

    > Or use AppleScript/AppleEvents, which have a built-in "quit" message
    > for
    > any regular app.

    Example:

    -(OSStatus)quitApplicationWithBundleID:(NSString *)bundleID {
        OSStatus err;
        AppleEvent event, reply;

        const char *bundleIDString = [bundleID UTF8String];

        err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication,
                                typeApplicationBundleID,
                                bundleIDString, strlen(bundleIDString),
                                kAutoGenerateReturnID, kAnyTransactionID,
                                &event, NULL, "");

        if (err) return err;
        err = AESendMessage(&event, &reply, kAENoReply, kAEDefaultTimeout);
        AEDisposeDesc(&event);
        return err;
    }

    has
    --
    http://appscript.sourceforge.net
    http://rb-appscript.rubyforge.org
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today