[Lazarus] SendMessage Bug Work Around.

José Mejuto joshyfun at gmail.com
Thu Apr 22 15:17:31 CEST 2010


Hello Lazarus-List,

Thursday, April 22, 2010, 2:43:04 PM, you wrote:

JS> I dont know if many of you guys who use win32 are aware of a bug /
JS> limitation of sendmessage in windows , when you are trying to send a message
JS> to another application , when the message gets there both lparam and wparam
JS> are invalid ( or pointing to rubish ) ( i also got the same issue on

You can not send data to other applications using pointers and
sendmessage because they are in a different process so memory is not
shared, so it is not a but nor limitation is a "by design" to allow
process isolation. Windows have a special message to send data to
other processes, but the amount of data is limited and it must be
copied (I think it is transparent) to a shared memory.

JS> the best work around i've found is to use a NamedPipe which i know is win32
JS> only ( not sure about other os's ) , i basically created a "ServerPipe" and
JS> a "ClientPipe" and use this pipe to send info from the second application
JS> back to my main application to get around the sendmessage issue.
JS> I know alot of you guys are not using win32 but other variants of linux but
JS> for the people who are using win32 this maybe of interest if you have got
JS> issues with SendMessage on win32.

A Pipe is designed just to to such things and they are more or less
like sequential files and they share a lot of semantics. Other
difference is thay pipes are not usually written to any media.

JS> My Os is Win7 RTM on one pc and Win7 Retail on the other - both ultimate 64
JS> bit. & i am using pritty much the lastest SVN
JS> i also suspect this method may help anyone using a DLL who needs to pass
JS> objects back and forth ( i think havent tested but i think it should be
JS> feasable.. )

A DLL shares the same process so you can use SendMessage or more
simple a direct call to an exported procedure. A different beast is
that the DLL has its own memory manager and its own RTL which is a
problem to some LCL operations.

-- 
Best regards,
 José





More information about the Lazarus mailing list