Solved

Quiting another app with an Apple Event

Posted on 2000-04-13
2
261 Views
Last Modified: 2013-12-26
How would I tell another application  to quit using an Apple Event. I have found that the program is running using FindAProcess(). How would I code this. I tried messing with other AE code that I have but it doesn't work.
0
Comment
Question by:dwp090598
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
munsie earned 100 total points
ID: 2717579
this code is from just_finder.c on the apple sample code website (www.apple.com/developer  look for a sample code link on the sidebar)

this is the part that should do what you want.  The original code didn't do any of this until WaitNextEvent() returned a null event.  You may or may not, depending on your program.

it's assumed that you already have the correct headers you need, and so forth.

--------

OSErr myErr = AECreateDesc(typeProcessSerialNumber, (Ptr)&theProcess, sizeof(theProcess), &ourPSNDesc);
if (myErr == noErr)
{
                        
// Create the 'quit' Apple event for this process.  This might return error
// -603 for desk accessories if you don't call WaitNextEvent enough times
// like above.
                        
myErr = AECreateAppleEvent(kCoreEventClass,kAEQuitApplication, &ourPSNDesc, kAutoGenerateReturnID, kAnyTransactionID, &ourQuitEvent);
if (myErr == noErr)
{
// send the event
myErr = AESend(&ourQuitEvent, &ourReplyEvent, kAENoReply, kAENormalPriority, kNoTimeOut, 0L, 0L);
if (myErr == noErr)
{
// Sadly, some applications won't respond to Apple events and do
// what they're supposed to do until they're brought to the front,
// so we do that, and continue our work in the background.

SetFrontProcess(&theProcess);
}

// dispose of the event only if we succesfully created it.
myErr = AEDisposeDesc(&ourQuitEvent);
}
                        
// dispose of the descriptor only if we succesfully created it.
myErr = AEDisposeDesc(&ourPSNDesc);
}

------

good luck,
dennis
0
 

Author Comment

by:dwp090598
ID: 2720234
Worked perfect.

THank You
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question