Отправка сообщения в очередь.
BOOL CMQMsgDlg::SendMQMessage
( csQueueName )
{
BOOL bRet = FALSE;
LPWSTR wszMessage;
MQMSGPROPS mqMessageProps;
MSGPROPID aPropID[1];
MQPROPVARIANT aPropVar[1];
HRESULT aStatus[1];
CString csText;
QUEUEHANDLE hQueue;
if( OpenQueue( csQueueName,&hQueue ) )
{
m_ctrlMessage.GetWindowText( csText );
if( csText.GetLength() > 0 )
{
if( AnsiToUnicode( csText,&wszMessage ) )
{
mqMessageProps.cProp = 1;
mqMessageProps.aPropID = aPropID;
mqMessageProps.aPropVar = aPropVar;
mqMessageProps.aStatus = aStatus;
aPropID[0] = PROPID_M_BODY;
aPropVar[0].vt = VT_VECTOR | VT_UI1;
aPropVar[0].caub.pElems =
(UCHAR*)wszMessage;
aPropVar[0].caub.cElems =
wcslen(wszMessage);
aStatus[0] = 0;
bRet = ( MQSendMessage
( hQueue,&mqMessageProps,NULL )
== MQ_OK );
delete wszMessage;
}
}
MQCloseQueue( hQueue );
}
return bRet;
}