If it has to be C or C++ then you will have to send and AppleEvent to the application in question. This is not all that simple to achieve. It's easier to use AppleScript:
tell application "name" to quit
If you were using Objective C/Cocoa then you could use NSAppleScript.
If it has to be C/C++ then you are probably stuck with the complex and ugly Apple Event Manager
Note that if you are in C it might be easier to shell out and use osascript -e 'tell application "name" to quit' than to use the Event Manager...
Robbieduncan, is it possible using AppleScript to catch events from application. For example: If user opens QuickTime player and begin to preroll movie I must know what he do now. Is it possible with AppleScript?
Unless the application chooses to send an event then no, there is no automatic way to know when a specific event happens in another app that I know of.
Robbieduncan, is it possible using AppleScript to catch events from application. For example: If user opens QuickTime player and begin to preroll movie I must know what he do now. Is it possible with AppleScript?
AppleScript can be recorded off of some applications. Implementing it has always been a pain and with a bunch of changes to make adding scriptability easy, nothing really has been done to make recordability easy.
On possible option is that quicktime movies can trigger actions, but that means you need control over the movie.
You may want to make your own movie player if that is all you looking for. Its fairly easy to do with cocoa and interface builder. Then you can key off of the movie player itself.