target address
Specifying a Target Address
When you create an Apple event, you must specify the address of the target.
The target address identifies the particular application or process that you
want to send the Apple event to. You can send Apple events to applications on the
local machine or on remote computers on the network.
These are the descriptor types that identify the four methods of addressing an Apple event.
typeApplSignature The application signature of the target typeSessionID The session ID of the target typeTargetID The target ID record of the target typeProcessSerialNumber The process serial number of the target To address an Apple event to a target on a remote computer on the network,
you must use either the typeSessionID or typeTargetID descriptor type.
If your application sends an Apple event to itself, it should address the Apple
event using a process serial number. Use the kCurrentProcess constant to
specify the process serial number of your application. This is the fastest way
for your application to send an Apple event to itself.
You can use any of the four address types when sending an Apple event to
another application on the local computer. To allow the user to choose the
function presents a standard user interface for choosing a target application,
opening and saving files.
The PPCBrowser function returns information about the application the user chose in a target ID record.
also use another address type, if it also provides a coercion handler that
coerces the address type into one of the four address types that the
You specify the address using an address descriptor record (a
descriptor record of this type and then supply the address
You can use the AECreateDesc function to add any of the four target addresses to an address descriptor record. The following program shows four
possible ways to create an address, each using a different address type.
Creating a target address
// Assuming inclusion of
#include <AppleEvents.h>
{
sizeof (* toTargetID), targetAddress1);
sizeof (*thePSN), targetAddress2);
sizeof(theSignature), targetAddress3);
sizeof(theSessionRef), targetAddress4);
// add your own error checking
}
You specify the descriptor type for the address, a pointer to the buffer
containing the address, and the size of the buffer to the AECreateDesc function to create an address descriptor record. The AECreateDesc function returns an address descriptor record with the specified characteristics.
After creating an address, you can specify the address in the
the Apple event.
You can use the PPCBrowser function to create a target ID record. The following program shows how to use the information returned from the
PPCBrowser function to create a target ID record. You can then use AECreateDesc to create the address descriptor record for an Apple event. // Specifying a target address in an Apple event by using the
// Assuming inclusion of
#include <AppleEvents.h>
void DoError (OSErr myErr); {
&( toTargetID-> location), myPortInfo, nil, "\p");
if (! myErr)
DoError ( myErr);
else {
toTargetID->name = myPortInfo->name;
// Create the descriptor record for the target address)
sizeof(* toTargetID), targetAddress);
if (! myErr)
DoError( myErr);
}
// add your own error checking
return myErr;
}