Thread View: borland.public.csharpbuilder.language.csharp
3 messages
3 total messages
Started by Ray
Thu, 18 Jan 2007 18:04
Pointer to memory blocks
Author: Ray
Date: Thu, 18 Jan 2007 18:04
Date: Thu, 18 Jan 2007 18:04
31 lines
1763 bytes
1763 bytes
Hi
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);
}
Re: Pointer to memory blocks
Author: Marc Rohloff TeamB
Date: Thu, 18 Jan 2007 19:45
Date: Thu, 18 Jan 2007 19:45
25 lines
1980 bytes
1980 bytes
On Thu, 18 Jan 2007 18:04:02 -0000, Ray wrote: > 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
Re: Pointer to memory blocks
Author: Ray
Date: Fri, 19 Jan 2007 18:45
Date: Fri, 19 Jan 2007 18:45
37 lines
2135 bytes
2135 bytes
Thanks Marc 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:1iwcargjbfba8.dlg@dlg.marcrohloff.com... > On Thu, 18 Jan 2007 18:04:02 -0000, Ray wrote: > >> 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads