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.
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;