https://stackoverflow.com/questions/5291815/quitting-other-applications-in-cocoa
We use -[NSWorkspace runningApplications]
. It requires 10.6 or higher.
void SendQuitToProcess(NSString* named)
{
for ( id app in [[NSWorkspace sharedWorkspace] runningApplications] )
{
if ( [named isEqualToString:[[app executableURL] lastPathComponent]])
{
[app terminate];
}
}
}
otherwise, you'll have to use AppleScript. You can do something corny like this:
void AESendQuitToProcess(const char* named)
{
char temp[1024];
sprintf(temp, "osascript -e \"tell application \\\"%s\\\"\" -e \"activate\" -e \"quit\" -e \"end tell\"", named);
system(temp);
}