Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to send binary objects as body in C++ / COM

75 views
Skip to first unread message

Akbar

unread,
Jan 13, 2009, 5:02:00 PM1/13/09
to
Could some one please explain me how to send / receive an object as
Body in MSMQ message as we do in C#.
With the following code I can only send a string. Could you please let
help me send an object.

IMSMQQueueInfoPtr qInfo("MSMQ.MSMQQueueInfo");;
qInfo->PathName = ".\\radtriton7";
IMSMQQueuePtr qSend;
IMSMQMessagePtr m("MSMQ.MSMQMessage");
qSend = qInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
vtMessage.SetString("Test",VT_BSTR);
vtLabel.SetString("Test",VT_BSTR);
m->Body = ((LPVARIANT)vtMessage)->bstrVal;
m->Label = ((LPVARIANT)vtLabel)->bstrVal;
m->Send(qSend);
qSend->Close();

Thanks.

Frank Boyne

unread,
Jan 13, 2009, 7:19:55 PM1/13/09
to
"Akbar" <asakb...@gmail.com> wrote in message
news:c8ccb924-395f-4be3...@k19g2000yqg.googlegroups.com...

> Could some one please explain me how to send / receive an object as
> Body in MSMQ message as we do in C#.

I'm afraid you can't really do that. In C# by default MSMQ uses
something called the XmlMessageFormatter to serialise an object into a
stream of bytes suitable for transmission in an MSMQ message body.

The MSMQ COM API has a more limited mechanism for serializing messages
into a message body. The COM API is limited to serialising Variants and
COM objects that support IPersistStream or IPersistStorage
http://msdn.microsoft.com/en-us/library/ms705708(VS.85).aspx

The equivalent in C# would be using the ActiveXMessageFormatter.

> With the following code I can only send a string. Could you please let
> help me send an object.

About the closest we can come is something like this...

_variant_t someObject = // construct the variant some how
m->Body = someObject;

0 new messages