If you're crossing a process boundary with your message a simple pointer
is not sufficient.
For the OS a message is a simple struct with a WPARAM and a LPARAM
inside.
Inprocess you can easily cast pointers to these, but that crashes when
the receiving window lives in a different process.
I don't know if I remember correctly, but maybe a HGLOBAL allocated with
GlobalAlloc(GHND) could give you a appropriate piece of memory; but
that's long ago and maybe wrong advise.
However you need some memory that both processes can access.
So you have some additional work in front of your problem ;-)
When you have the memory pointer you can access it with standard pointer
syntax:
byte *x = GlobalLock();
or to lock managed memory
byte[] arr = new byte[1024]
fixed( byte* pArr = arr )
{
// pointer operations
}
Good luck
Axel
PS:
It's much cleaner to use a COM object or .net remoting for these
matters...
-----Original Message-----
From: Jan Dropczynski [mailto:[EMAIL PROTECTED]]
Sent: Freitag, 26. April 2002 13:50
To: [EMAIL PROTECTED]
Subject: [DOTNET] Send data with SendMessage
Hi all,
I want to use the SendMessage with my own message command
to send data to another application. In the specific case
a string array should be sent to the receiving appilcation.
But how can I do that?
The idea is to serialize the string array to a MemoryStream
to get a byte array from it. And then I use a pointer to that
byte array for use with SendMessage.
To use pointers in C# I have to work with an unsafe code block
but how can I declare an unmanaged byte array in the unsafe
code block?
Regards,
Jan Dropczynski
Software-Engineer
THONA Consulting Ltd.
You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.