Memory allocated in one app cannot be referenced in another app. Each app runs in it's own memory space, so WM_COPYDATA is a good option.
Ross. > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] On Behalf Of Allan Vergara > Sent: Wednesday, 22 January 2003 12:28 > To: Multiple recipients of list delphi > Subject: [DUG]: Sending record > > > Is it possible to send a record (via SendMessage) from one > application to another without using WM_COPYDATA? > > I have two test apps and both are registered to receive the > same message. The receiving app seems to receive the message > okay, but when I tried to dereference the pointer all I got > is garbage. > > My code: > > THello = record > Name :PChar; > Address :PChar; > Pin :Integer; > end; > > var > h :THello; > WM_MY_MESSAGE :WORD; > ... > > implementation > ... > var > ReceiverHWND :Integer; > begin > with h do begin > Name:= 'Allan'; > Address:= '123 Avenue'; > Pin:= 123; > end; > > ReceiverHWND := FindWindow('TDlgReceiver', 'Receiver'); > //assuming the window exists > SendMessage(Receiver, WM_MY_MESSAGE, LongInt(@h), 0); > end; > > //receiver code > procedure TDlgReceiver.WndProc(var Message :TMessage); > var > h :THello; > begin > if message.msg = WM_MY_MESSAGE then > h:= THello(@(Message.WMParam)^); //GARBAGE > ... > end; > > Thanks in advance :) > > > -------------------------------------------------------------- > ------------- > New Zealand Delphi Users group - Delphi List - > [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
