I use the following to share a shortstring between 2 executables:
Type
PInstanceInfo = ^TInstanceInfo;
TInstanceInfo = packed record
MainAppHandle: THandle;
SessionPath: String[255];
end;
Var MappingHandle: THandle;
InstanceInfo: PInstanceInfo;
MappingHandle := CreateFileMapping(INVALID_HANDLE_VALUE,
nil,
PAGE_READWRITE,
0,
SizeOf(TInstanceInfo),
PChar('MyApp'));
InstanceInfo := MapViewOfFile(MappingHandle, FILE_MAP_ALL_ACCESS, 0, 0, SizeOf(TInstanceInfo));
InstanceInfo^.MainAppHandle := Application.Handle;
I use SessionPath to store the path to a file. This works fine when both apps are x86 or x64, but when App1 is 32-bit and App2 is 64-bit, App2 is missing the first 4 characters of the string when I read it. What's different in the ShortString structure in this case?