Открываем очередь сообщений.
BOOL CMQMsgDlg::OpenQueue
( LPCTSTR szQueueName,QUEUEHANDLE* hQueue,DWORD dwAccess,DWORD dwShareMode )
{
DWORD dwFormatNameLength = 0;
BOOL bRet = FALSE;
WCHAR* wszFormatName;
WCHAR* wszName;
HRESULT hRes;
if( AnsiToUnicode( szQueueName,&wszName ) )
{
if( (hRes = MQPathNameToFormatName
( wszName,NULL,&dwFormatNameLength )) ==
MQ_ERROR_FORMATNAME_BUFFER_
TOO_SMALL )
{
wszFormatName = new WCHAR[dwFormatNameLength + sizeof(WCHAR)];
if( wszFormatName != NULL )
{
memset
( wszFormatName,0,dwFormatNameLength
+ sizeof(WCHAR) );
if( MQPathNameToFormatName
( wszName,wszFormatName,
&dwFormatNameLength ) == MQ_OK )
{
if( MQOpenQueue
( wszFormatName,dwAccess,
dwShareMode,hQueue ) == MQ_OK )
bRet = TRUE;
}
delete wszFormatName;
}
}
delete wszName;
}
return bRet;
}