By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 1,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

Passing objects in windows messages

P: n/a
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.
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
* "Nak" <a@a.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

P: n/a
Nak
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.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
* "Nak" <a@a.com> scripsit:
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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3

P: n/a
Nak
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" <a@a.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
Okie dokie, so I am sending Structures okay now, which is pretty handy,
cheers for the info!

Nick.

"Nak" <a@a.com> wrote in message
news:um**************@TK2MSFTNGP11.phx.gbl...
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.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eV**************@TK2MSFTNGP10.phx.gbl...
* "Nak" <a@a.com> scripsit:
> 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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>



Nov 20 '05 #4

P: n/a
I think that is called serialization and deserialization.

"Nak" <a@a.com> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
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.

Nov 20 '05 #5

P: n/a
Nak
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.

"Gavin Jacobs" <no********@inhell.net> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl...
I think that is called serialization and deserialization.

"Nak" <a@a.com> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
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.


Nov 20 '05 #6

P: n/a
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/de...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/de...us/fileio/base
/creating_named_shared_memory.asp

Choosing Communication Options in .NET
http://msdn.microsoft.com/library/de...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.

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.