在Windows2000的消息队列服务里,建立一个专用队列,请问应用程序如何操作这个专用队列呢?
解决方案 »
- vs2008或2010“添加新数据源”出现的问题
- win2000下 vc编的程序无法启动问题
- 看别人的程序,如果在ClassWizzard中根据ID号找到响应函数
- CHttpConnection怎么会连到别的IP地址去?
- 虽然知道再问下去会被讨厌,但还是要问
- 关于广播的问题.高手们请指点
- 想知道一下如何能简单编程实现avi格式转成gif格式?
- 【求教大虾】怎样用VC来开发一个FTP的服务器端呢?
- VC导出excel代码中有一个变量不知什么类型,请教了
- 哪位大哥帮我解释一下这段代码的意思啊!
- 谁有WDM开发的电子书籍?
- 我发现当CListCtrl的几个ITEM被选中后,鼠标点击别的控件,这些ITEM项的选中焦点就不见了,如何解决?
{
// TODO: Add your dispatch handler code here
const int NUMBEROFPROPERTIES = 5;
DWORD cPropId = 0; MQMSGPROPS MsgProps;
MSGPROPID aMsgPropId[NUMBEROFPROPERTIES];
MQPROPVARIANT aMsgPropVar[NUMBEROFPROPERTIES];
HRESULT aMsgStatus[NUMBEROFPROPERTIES];
HRESULT hr = MQ_OK;
// Set message properties.
WCHAR* wchDestQueueFormatName = (WCHAR*)malloc(2*strlen(sForamtAddr)+2);
memset(wchDestQueueFormatName,0,2*strlen(sForamtAddr)+2);
int ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sForamtAddr, strlen(sForamtAddr), wchDestQueueFormatName,strlen(sForamtAddr));
if(!ret)
{
free(wchDestQueueFormatName);
return FALSE;
}
TRACE("---DestQueueForamt--------%S\n",wchDestQueueFormatName); WCHAR pwLable[32];
memset(pwLable,0,2*32);
int cchWideChar = 32; aMsgPropId[cPropId] = PROPID_M_LABEL_LEN; // Property ID
aMsgPropVar[cPropId].vt =VT_UI4; // Type indicator
aMsgPropVar[cPropId].ulVal = 64; // Label buffer size
cPropId++; ret = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sLable, strlen(sLable), pwLable,cchWideChar);
if(!ret)
{
free(wchDestQueueFormatName);
return FALSE;
}
aMsgPropId[cPropId] = PROPID_M_LABEL;
aMsgPropVar[cPropId].vt = VT_LPWSTR;
aMsgPropVar[cPropId].pwszVal = pwLable;
cPropId++;
TRACE("-----Lable------%S\n",pwLable);
aMsgPropId[cPropId] = PROPID_M_BODY;
aMsgPropVar[cPropId].vt = VT_UI1|VT_VECTOR;
aMsgPropVar[cPropId].caub.cElems = strlen((const char *) sBody);
aMsgPropVar[cPropId].caub.pElems = (unsigned char *)sBody;
cPropId++;
TRACE("-------Body-----%s\n",sBody); // Initialize the MQMSGPROPS structure.
MsgProps.cProp = cPropId; // Number of message properties
MsgProps.aPropID = aMsgPropId; // IDs of the message properties
MsgProps.aPropVar = aMsgPropVar; // Values of the message properties
MsgProps.aStatus = aMsgStatus; // Error reports
// Call MQOpenQueue to open the queue with send access.
HANDLE hQueue = NULL;
hr = MQOpenQueue (
wchDestQueueFormatName, // Format name of the queue
MQ_SEND_ACCESS, // Access mode
MQ_DENY_NONE, // Share mode
&hQueue
); // OUT: Queue handle
if (FAILED(hr))
{
free(wchDestQueueFormatName);
return FALSE;
}
// Call MQSendMessage to send the message to the opened queue.
hr = MQSendMessage(
hQueue, // Queue handle
&MsgProps, // Message property structure
MQ_NO_TRANSACTION
);
if (FAILED(hr))
{
free(wchDestQueueFormatName);
MQCloseQueue(hQueue);
return FALSE;
}
// Call MQCloseQueue to close the queue.
hr = MQCloseQueue(hQueue);
free(wchDestQueueFormatName);
return TRUE;
}