在Windows2000的消息队列服务里,建立一个专用队列,请问应用程序如何操作这个专用队列呢?
解决方案 »
- 求救,vc2008工程的rc文件误删了,怎么办
- 怎么用MFC做一个大文本的浏览器?
- 测试某站点是否可用?
- 什么方案能解决上传速度小的问题,言者有分,一共100,谢谢
- 求一用VC编写的FTP客户端的源程序
- 请问Create和new有什么本质的区别~(内有具体问题)
- 小菜鸟一只,毕设是SPI防火墙,纯应用层的,端口拦截方面有很大的bug,求好心人帮我看看代码……
- 请教!!
- 对话框中如何添加菜单?
- 对BOOL CALLBACK DialogProc::DialogProc(HWND hwnd, 中hwnd 句柄怎么获取
- 谁有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;
}