Dear all,
I want to use shared data between two Lazarus applications using the Windows FileMapping mechanism. Please have a look at the attached test project.
In fact, I need to pass a variable string length from the caller to the receiver. The length can grow up to several KB of data. In the test application, a data structure has been defined and it contains a variable of type string.
TData = packed record
FUniqueID: DWORD;
FName: string;
end;
The variable FName is initialized as follow (TForm1.SendClick) :
Data is correctly exchanged when clicking on the "Send" and then "Receive" button, even between TWO instances. Large strings of more than 800 characters also work without problems.
Now, initialization code is changed to :
Data.FName := 'ABC-';
Data.FName := Data.FName + 'DEF';
For ONE instance, it still works fine.
When you launch TWO instances of the compiled application, and click "Send" in the first one and then "Receive" in the second instance, some garbage data is transmitted, but not the requested data. In the message dialog, the text for the label "Name" may be empty or the "Receiver" application may crash.
I tried so many things and can't get it working. Maybe it's just a small adjustment.
How can I get this working ?
Many thanks for your help,
Romain