Hey all,
I hope Apple Event questions are OK here. As usual, this is so simple that of course I have been struggling with it for 2 days now.
All I want to do is send the Quit Apple Event to iSync, from C code. I’m doing this to learn and to make an automatic sync for a USB connected phone, so I already have the code to get notifications when the phone is plugged in and that works fine.
This is just a simple C app to make an Apple Event and send it to iSync. When I trace through it, it returns error -600 “procNotFound”, which means that the Application address I am sending isn’t correct. As per the Panther Tech Note, I am using the recommended kApplicationBundleID constant and passing 4 for the length, but I don’t think that is correct.
Please take a look and tell me why the AESend function can’t find the app “iSync” (I suspect that the application address isn’t in the AEDesc properly).
[code]#include <Carbon/Carbon.h>
#include <ApplicationServices/ApplicationServices.h>
int main(int argc, char *argv[])
{
OSErr err;
char *iSyncBundleID = “com.apple.isync”;
AppleEvent doSyncEvent;
AEAddressDesc iSyncAddress;
err = AECreateDesc(typeApplicationBundleID,
&iSyncBundleID,
sizeof(iSyncBundleID),
&iSyncAddress);
err = AECreateAppleEvent(
kCoreEventClass,
kAEQuitApplication,
&iSyncAddress,
kAutoGenerateReturnID,
kAnyTransactionID,
&doSyncEvent);
err = AESend(
&doSyncEvent,
NULL,
kAENoReply | kAECanInteract,
kAENormalPriority,
kAEDefaultTimeout,
NULL,
NULL);
err = AEDisposeDesc(&doSyncEvent);
return err;
}[/code]
All this should do is send a Quit to iSync. The error I get is that AESend can’t find the target. The target address should be in the iSyncAddress descriptor, and from there put into the Apple Event doSyncEvent.
Thanks in advance.
Johnny