IMSMQQueuePtr qDest; // Represents Destination Queue
IMSMQQueueInfoPtr qInfo; //Represents an open instance of the destination queue
IMSMQQueueInfoPtr qRead;
IMSMQMessagePtr qMsg; //Represents the message
初始化
qDest = NULL;
CoInitialize(NULL);
try{
qInfo.CreateInstance("MSMQ.MSMQQueueInfo");
qRead.CreateInstance("MSMQ.MSMQQueueInfo");
qMsg.CreateInstance("MSMQ.MSMQMessage");
lpszSystemInfo = tchBuffer;
GetComputerName(lpszSystemInfo,&cchBuff); // Getting the ComputerName
m_ServerName=lpszSystemInfo;
UpdateData(FALSE);
}
catch (_com_error)
{
MessageBox("Failed in CreateInstance of MSMQQueueInfo","MSMQ QueueInfo",1);
PostQuitMessage(1);
ReleaseAll();
}
创建消息队列
try
{
// m_ServerName = .\Private$\aaa 创建专有队列
// m_ServerName = .\aaa 公用队列
//
// qInfo->PathName = m_ServerName.AllocSysString(); // Setting the Queue Path
CString fname;
fname="DIRECT=OS:";
fname+=m_ServerName;
qInfo->PathName = m_ServerName.AllocSysString();
qInfo->FormatName = fname.AllocSysString();
qInfo->Label= m_msgLabel.AllocSysString(); // Setting the Queue Label
ht = qInfo->Create();
qInfo->Journal=1; // Enabling the Journal Option
qInfo->Update();
qInfo->Refresh();
}
catch (_com_error e)
{
CString str;
str.Format("%s",e.ErrorMessage());
MessageBox("Creating a Queue Failed","Create Queue",1);
//ReleaseAll();
}
本文来自 280文秘网(https://www.it280.com),转载请保留网址和出处
【vc操作微软消息队列的方法】相关文章:
2025年外省高中学业水平合格性考试成绩转入江苏认定的通告公布03-23
2012宁夏高考报名方式03-23
Vb中控件的自动排列03-23
写未来的作文300字03-23
Our Mother Is the Same 我们的妈妈是一样的03-23
小学父爱的作文600字03-23
荷花作文600字03-23
寓言作文300字03-23
汪涵讲述小时候成长经历:鸡毛掸子的故事03-23
关于清明节的英语作文:清明节03-23
嘿我成功了作文03-23
