I am trying to transfer data from one application to another by sending a
pointer to a memory block. To test this out I have two applications, a
sender and a receiver. The sender fills an integer buffer and sets a pointer
to its address. Then I send a message via the interop SendMessage();.
I get the message in the Receiver ok and the pointer value received is the
same as the one sent. But when I try to get the data all I get is garbage.
To simplify things both applications are set as an unsafe class;
Send code is
fixed(int* p1=outbuff)
{
SendMessage(recHandle, msg, (IntPtr)(p1),(IntPtr)(p1));
}
Receive code is
protected override void WndProc(ref Message m)
{
if(m.Msg==msg)
{
int* pptr=(int*)m.WParam.ToPointer();
for(int i=0;i<100;i++) richTextBox1.AppendText(i+";
"+(*pptr++).ToString()+"\n");
}
base.WndProc(ref m);
}
> I am trying to transfer data from one application to another by sending a
> pointer to a memory block. To test this out I have two applications, a
> sender and a receiver. The sender fills an integer buffer and sets a pointer
> to its address. Then I send a message via the interop SendMessage();.
>
> I get the message in the Receiver ok and the pointer value received is the
> same as the one sent. But when I try to get the data all I get is garbage.
You cannot send memory between applications by just sending a pointer.
Each application addresses its own unique memory space and contents.
You need to use one of:
1) TCP/IP
2) Webservices, remoting, etc.
3) Shared memory, Memory Mapped Files, etc
4) The WM_COPYDATA windows message
5) Real files
6) etc
--
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Can you point me in the direction of some info on 3) Shared memory, Memory
Mapped Files, etc
Ray
"Marc Rohloff [TeamB]" <"on request"> wrote in message
news:1iwcargj...@dlg.marcrohloff.com...