InterAppComm consists of two components, InterAppSender and InterAppReceiver, which can communicate between separate applications running on the same machine. The communication occurs conveniently through the use of events.
Typically you place a sender in one application and a receiver in one or more other applications. The sender can determine how many receivers are currently running and can send data to them in various formats (string, integer, real, or custom format). It can also detect a receiver being created, destroyed, enabled, or disabled.
The sender can communicate with all running receivers or just a group of receivers sharing the same group name.
Enabled | property Enabled: Boolean; When enabled, the component will accept events issued from InterAppReceiver objects. |
Default true |
Handle | property Handle: HWND; The component's handle. |
Read-only |
Call | type THandleArray = array of THandle; function Call(Silent: Boolean): THandleArray; Broadcasts a message which all running InterAppReceiver objects respond to (unless they are not enabled). For each receiving object its OnReceiveCall event method will fire, and it will automatically reply to the sender, causing the sender's OnReceiverReply event method to fire. Parameters: If the Silent parameter is true the sender and receiver will not generate any events. Return value: Returns an array containing the handles of all running, enabled InterAppReceiver objects. |
CallGroup | type THandleArray = array of THandle; function CallGroup(GroupName: ShortString; Silent: Boolean): THandleArray; The same as Call, except only receivers with a matching GroupName property are targeted. For each receiving object with a matching GroupName its OnReceiveCall event method will fire, and it will automatically reply to the sender, causing the sender's OnReceiverReply event method to fire. Parameters: GroupName is the group name of the targeted receivers. If the Silent parameter is true the sender and receiver will not generate any events. Return value: Returns an array containing the handles of all running, enabled InterAppReceiver objects with the specified GroupName. |
SendString | procedure SendString(Receiver: HWND; Text: ShortString); Sends a ShortString (max. 255 chars) to the InterAppReceiver object specified by Receiver, causing its OnReceiveString event method to fire. Parameters: Receiver is the handle of the InterAppReceiver object for which the transfer is intended. Text is the text to send. |
SendInteger | procedure SendInteger(Receiver: HWND; Value: Longint); Sends a Longint value to the InterAppReceiver object specified by Receiver, causing its OnReceiveInteger event method to fire. Parameters: Receiver is the handle of the InterAppReceiver object for which the transfer is intended. Value is the value to send. |
SendReal | procedure SendReal(Receiver: HWND; Value: Real); Sends a Real value to the InterAppReceiver object specified by Receiver, causing its OnReceiveReal event method to fire. Parameters: Receiver is the handle of the InterAppReceiver object for which the transfer is intended. Value is the value to send. |
SendData | procedure SendData(Receiver: HWND; Data: Pointer; DataSize: Cardinal); Sends custom data to the InterAppReceiver object specified by Receiver, causing its OnReceiveData event method to fire. Parameters: Receiver is the handle of the InterAppReceiver object for which the transfer is intended. Data is a pointer to the custom data to send. The format must be known to the sender. Use a packed record as data. DataSize is the size of the data referenced by Data (use SizeOf to determine it). NOTE: The sender and receiver must adhere to the same format in order to exchange meaningful data (and avoid access violation errors). NOTE: Don't use Data to transfer pointers as they'll be invalid outside the sending application. EXAMPLE: InterAppSender1.SendData(H, @MyRecord, |
OnReceiverReply | procedure(Sender: TObject; ReceiverHandle: HWND) of object; Fired when the component receives a reply from an InterAppReceiver object, in response to the Call or the CallGroup method. ReceiverHandle is the handle of the InterAppReceiver object. |
OnReceiverCreated | procedure(Sender: TObject; ReceiverHandle: HWND) of object; Fired when a new InterAppReceiver object is created. |
OnReceiverDestroyed | procedure(Sender: TObject; ReceiverHandle: HWND) of object; Fired when an InterAppReceiver object is destroyed. |
OnReceiverEnabled | procedure(Sender: TObject; ReceiverHandle: HWND) of object; Fired when a previously disabled InterAppReceiver object is enabled. |
OnReceiverDisabled | procedure(Sender: TObject; ReceiverHandle: HWND) of object; Fired when a previously enabled InterAppReceiver object is disabled. |
Enabled | property Enabled: Boolean; When enabled, the component will respond to calls and data transfers from InterAppSender objects. |
Default true |
Handle | property Handle: HWND; The component's handle. |
Read-only |
GroupName | property GroupName: ShortString; The GroupName property can be used to define a group of receiver objects. Setting GroupName to some unique string and only using InterAppSender's CallGroup method (rather than Call) ensures you don't inadvertently communicate with other applications containing InterAppReceiver objects. |
OnReceiveCall | procedure(Sender: TObject; SenderHandle: HWND) of object; Fired when an InterAppSender object broadcasts a call, using the Call or the CallGroup method (with the Silent parameter set to false). The InterAppReceiver object will automatically send a reply (unless it is not enabled). NOTE: SenderHandle is the handle of the InterAppSender object. Don't confuse it with Sender. |
OnReceiveString | procedure(Sender: TObject; SenderHandle: HWND; Text: ShortString) of object; Fired in response to an InterAppSender object sending a string, using the SendString method. NOTE: The string is a ShortString (max. 255 chars). |
OnReceiveInteger | procedure(Sender: TObject; SenderHandle: HWND; Value: Longint) of object; Fired in response to an InterAppSender object sending a Longint value, using the SendInteger method. |
OnReceiveReal | procedure(Sender: TObject; SenderHandle: HWND; Value: Real) of object; Fired in response to an InterAppSender object sending a Real value, using the SendReal method. |
OnReceiveData | procedure(Sender: TObject; SenderHandle: HWND; Data: Pointer; DataSize: Cardinal) of object; Fired in response to an InterAppSender object sending data, using the SendData method. NOTE: The sender and receiver must adhere to the same format in order to exchange meaningful data (and avoid access violation errors). |
Get the latest version from http://www3.brinkster.com/troels/delphi.asp.
Troels Jakobsen
delphiuser@get2net.dk