Board index » delphi » FastMM4 - Help with shared memory ?

FastMM4 - Help with shared memory ?


2006-11-27 11:25:42 PM
delphi34
Hi all,
I have to write something to help third party vendors to send strings
to my application.
What I thought was to write a simple DLL that shares Memory with my
application. Third parties just have to load the DLL and call the
"PainlessSendAStringToPierreApplication(What: PChar)"
I just have to remember my MainForm Handle to send it messages.
Host Application :
LoadLibrary('SendAStringToPierre.dll');
GetProcAddress(dllHandle, 'InitLibrary')
InitLibrary(Self.Handle)
DLL :
InitLibrary(Hnd: THandle)
begin
[shared] HostHandle := HostHandle; // here
end
PainlessSendAStringToPierreApplication(What: PChar) : Boolean; stdcall;
begin
if [shared] HostHandle = 0 then
Result := false
else
begin
Atom = GlobalAddAtom(What);
Result := SendMessage([shared] HostHandle,
WM_PIERREMESSAGE, Atom, 0) <>0;
GlobalDeleteAtom(Atom);
end;
end;
Third Party Application :
LoadLibrary('SendAStringToPierre.dll');
GetProcAddress(dllHandle, 'PainlessSendAStringToPierreApplication')
PainlessSendAStringToPierreApplication(PChar('Hello Pierre !'));
Can FastMM help me to share this memory or do I have to create shared
memory using CreateFileMapping/MapViewOfFile ?
... or do you have better ideas to achieve this ?
Best Regards,
--
Pierre Y.
 
 

Re:FastMM4 - Help with shared memory ?

"Pierre Y." <XXXX@XXXXX.COM>writes
Quote
Can FastMM help me to share this memory or do I have to create shared
memory using CreateFileMapping/MapViewOfFile ?
The borlndmm.dll can be used to share the same allocator within a single
process, between dll's for example, but not between processes.
For that you would indeed use something like a mmap or some other method of
sending data.
I would suggest using a window message that can hold data, skype uses that
mechanism, as do most applications with a separate tray icon application.
Quote

... or do you have better ideas to achieve this ?

Best Regards,
greets

--
Pierre Y.


 

Re:FastMM4 - Help with shared memory ?

Pierre Y. writes:
Quote
I have to write something to help third party vendors to send strings
to my application.
You might also look at named pipes.
Your app could have a pipe thread blocked on the named pipe (in the
dll)
Their app would call your dll to send the string through the pipe.
(Their interface would be the same as you wrote, just the internals
are different)