Solved

Quiting another app with an Apple Event

Posted on 2000-04-13
2
252 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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 116
Folder Comparison 12 55
Excel Use VBA to get user's Mac Address for their computer 5 409
Thin secure Windows 10 5 116
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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