Reputation: 985
I would like to know how to send and receive an object as "TPerson" between two different applications.
It would be possible using DataSnap? Is there another way?
Thanks.
Upvotes: 1
Views: 426
Reputation: 12322
An object instance is just a bunch of memory. Passing a dump of this memory from one application to another is a non sense, even if both applications are running on the same computer.
Instead, you can send the property values of the source object instance to the receiving application and apply the values to a local instance.
One easy way to do is to write a ToString() and a FromString() function to TPerson. Once you get a string from ToString, you can transmit it to the receiving application using any communication method (For example a TCP/IP socket, shared memory, email, FTP, HTTP or whatever fits your needs). The receiving application use FromString method to initialize the receiving object with the values embedded in the string.
ToString() and FromString() can be generically written by using RTTI. Or can simple be encode the old way in the class. JSON or XML libraries can help as well.
Upvotes: 0
Reputation: 598011
Objects cannot be passed across process boundaries. They have to be serialized, such as with COM or JSON.
Upvotes: 1