Passing objects in windows messages

  • Thread starter Thread starter Nak
  • Start date Start date
N

Nak

Hi there,

I was wondering if it was possible to pass objects in windows messages,
obviously via pointers I would presume, but I can't quite work out how to
turn an object into a pointer in VB.NET, if it is even possible of course?!?
Anyway, if anyone knows a way of doing this I would be most appreciative of
some advice, thanks yet again in advance!

Nick.
 
* "Nak said:
I was wondering if it was possible to pass objects in windows messages,
obviously via pointers I would presume, but I can't quite work out how to
turn an object into a pointer in VB.NET, if it is even possible of course?!?
Anyway, if anyone knows a way of doing this I would be most appreciative of
some advice, thanks yet again in advance!

I am just interested why you need this functionality.

BTW: What you are looking for should be possible with
limitations using the 'System.Runtime.InteropServices.Marshal'
class and structures that hold data.
 
Hi Herfried,

Why would I need this functionality? Because I am creating an object
that simplifies interprocess communication and enables the host to define a
custom protocol, my idea is that I shall be able to create a debugging
service for my applications as well as other things. I have used remoting
on a previous occasion, but I think this might be overkill and possibly
slower? I'm slightly fed up with my applications existing in a state of
blindness, I think this will be quite good, I have everything working
"spot-on" now, and thought it might be quite nice to be able to pass more
complex objects like strings and arrays. I hope this clarifies things a
little, cheers mate, I shall check out the Marshal namespace as you suggest.

Nick.
 
Okie dokie, so I am sending Structures okay now, which is pretty handy,
cheers for the info!

Nick.

Nak said:
Hi Herfried,

Why would I need this functionality? Because I am creating an object
that simplifies interprocess communication and enables the host to define a
custom protocol, my idea is that I shall be able to create a debugging
service for my applications as well as other things. I have used remoting
on a previous occasion, but I think this might be overkill and possibly
slower? I'm slightly fed up with my applications existing in a state of
blindness, I think this will be quite good, I have everything working
"spot-on" now, and thought it might be quite nice to be able to pass more
complex objects like strings and arrays. I hope this clarifies things a
little, cheers mate, I shall check out the Marshal namespace as you suggest.

Nick.

appreciative
 
Oh dear, tell a lie, it seems to be working when sending structures to the
same process, but when it comes to sending structures to another process
they come out garbled. The values are all wrong, any idea why this would
be?

Also, this might sound silly as well, but sometimes if I send "too many"
messages the application quits without exception, even if the messages are
handled and a value is returned using ReplyMessage. I must be doing
something very wrong because surely you can't send so many messsages to a
window that it crashes, or can you? Isn't that the point of blocking the
thread until a value is returned?

Nick.

Nak said:
Okie dokie, so I am sending Structures okay now, which is pretty handy,
cheers for the info!

Nick.

Nak said:
Hi Herfried,

Why would I need this functionality? Because I am creating an object
that simplifies interprocess communication and enables the host to
define
 
Hi Gavin,

Hmm, I hadn't thought of it like that, so storing a string in memory
that contains the XML serialized data for a class and passing the pointer to
that is your suggestion? I shall have to give it a whirl if poss. Cheers
for the idea.

Nick.
 
Hi Nick,

In windows NT world, every process has its own process space. That is to
say, certain memory address valid in process A will be invalid in process
B, so when you use sendmessge to send a point of certain memory to another
process the another process will cause problem.
For send data to another process, you may take a look at the WM_COPYDATA
message
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui
/windowsuserinterface/dataexchange/datacopy/datacopyreference/datacopymessag
es/wm_copydata.asp

If you will pass large object to another process, I suggest you use the
filemapping.
Creating Named Shared Memory
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base
/creating_named_shared_memory.asp

Choosing Communication Options in .NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconchoosingcommunicationoptionsinnet.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top