Click here to Skip to main content
11,478,066 members (72,173 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MSMQ
MQSendMessage throwing exception for simple "hello world" example. I am trying to write a simple send/receive for a private queue, nothing fancy.(non-transactional, events, etc) just simple strings. Queue is created successfully

code:
int sendMsg(std::string message, QUEUEHANDLE queuePtr)
{
	HRESULT status;
 
		MQMSGPROPS msgProperties;
		const int NUMBEROFPROPERTIES = 2;
		WCHAR tmpBodyMsg[] = L"RISQ first message";
 
		MSGPROPID msgPropertyID[NUMBEROFPROPERTIES];
		MQPROPVARIANT msgPropertyVariant[NUMBEROFPROPERTIES];
		HRESULT msgStatus[NUMBEROFPROPERTIES];
 

		int propIndex = 0;
 
		DWORD bodyType = VT_BSTR;
		msgPropertyID[propIndex] = PROPID_M_BODY_TYPE;
		msgPropertyVariant[propIndex].vt = VT_UI4;
		msgPropertyVariant[propIndex].ulVal = bodyType;
		propIndex++;
 
		msgPropertyID[propIndex] = PROPID_M_BODY;
		msgPropertyVariant[propIndex].vt = VT_VECTOR | VT_UI1;
		msgPropertyVariant[propIndex].caub.pElems = (LPBYTE)tmpBodyMsg;
		msgPropertyVariant[propIndex].caub.cElems =	sizeof(tmpBodyMsg);
		propIndex++;		
 

		// intialize MQQUEUEPROPS structure
		msgProperties.cProp = propIndex;
		msgProperties.aPropID = msgPropertyID;
		msgProperties.aPropVar = msgPropertyVariant;
		msgProperties.aStatus = msgStatus;
 

		status = MQSendMessage(queuePtr, &msgProperties, NULL);
		if(status != MQ_OK)
Posted 3-Nov-11 7:04am
Edited 3-Nov-11 7:30am
(no name)275.3K
v2
Comments
RaisKazi at 4-Nov-11 4:32am
   
Error Details?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 194
1 Richard Deeming 180
2 OriginalGriff 160
3 Sascha Lefèvre 145
4 Tomas Takac 130
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,256
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100