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/

Reply via email to