Click here to Skip to main content
15,897,371 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: COM object and global pointers Pin
led mike8-Jan-08 5:04
led mike8-Jan-08 5:04 
GeneralOleDb, IRowsetIndex Pin
ArielR7-Jan-08 3:38
ArielR7-Jan-08 3:38 
GeneralStatic controls transparency problem Pin
mirano6-Jan-08 10:19
mirano6-Jan-08 10:19 
GeneralRe: Static controls transparency problem Pin
Michael Dunn6-Jan-08 11:05
sitebuilderMichael Dunn6-Jan-08 11:05 
GeneralRe: Static controls transparency problem Pin
mirano6-Jan-08 11:52
mirano6-Jan-08 11:52 
GeneralRe: Static controls transparency problem [modified] Pin
Michael Dunn6-Jan-08 12:09
sitebuilderMichael Dunn6-Jan-08 12:09 
GeneralRe: Static controls transparency problem Pin
mirano7-Jan-08 0:34
mirano7-Jan-08 0:34 
GeneralMSMQ Pin
shakumar_221-Jan-08 22:27
shakumar_221-Jan-08 22:27 
Hi

Im creating an application in VC++ 6.0.

This application is ATL/COM service exe. in which i need to write certain inform to the queue as well reading data from different queue and perform some process.


I could able to write the given data to the specified queue but unable to read from the queue..


The code i have given below (only MSMQ receive part), while running below mentioned code im getting HR failure error. (no other error mentioned in msdn is not occuring)

can any could help me to get out of this issue...


//code:



HANDLE header1:pen_Queue(unsigned short *Qname)
{
MQQUEUEPROPS QueueProps;
PROPVARIANT aVariant[10]; // Modify for additional properties.
QUEUEPROPID aPropId[10]; // Modify for additional properties.
DWORD PropIdCount1 = 0;
HRESULT hr=MQ_OK;
HANDLE hQueue = NULL;
ULONG MSG_BODY_LEN;
// Queue handle

DWORD dwFormatNameBufferLength = 100;
WCHAR wszFormatNameBuffer[100];

PSECURITY_DESCRIPTOR pSecurityDescriptor;

// Set the pathname of the queue (PROPID_Q_PATHNAME).
aPropId[PropIdCount1] = PROPID_Q_PATHNAME; // Property identifier
aVariant[PropIdCount1].vt = VT_LPWSTR; // Type indicator
aVariant[PropIdCount1].pwszVal = Qname;
PropIdCount1++;

// Set the label of the queue (PROPID_Q_LABEL).
aPropId[PropIdCount1] = PROPID_Q_LABEL; // Property identifier
aVariant[PropIdCount1].vt = VT_LPWSTR; // Type indicator
aVariant[PropIdCount1].pwszVal = L"Test Queue"; // Queue label

PropIdCount1++;

///Set Queue Size
aPropId[PropIdCount1]=PROPID_Q_QUOTA;
aVariant[PropIdCount1].vt =VT_UI4;
aVariant[PropIdCount1].bVal=5 ;
PropIdCount1++;
////////////////////////////////////////////////////////
// Add additional properties here. When adding properties,
// increment the indexes for the aVariant and aPropId arrays
// in their respective declaration statements above.
////////////////////////////////////////////////////////


////////////////////////////////////
// Set the MQQUEUEPROPS structure.
/////////////////////////////////////
QueueProps.cProp = PropIdCount1; // Number of properties
QueueProps.aPropID = aPropId; // Ids of properties
QueueProps.aPropVar = aVariant; // Values of properties
QueueProps.aStatus = NULL; // No error reports
pSecurityDescriptor = NULL; // Set default security descriptor

////////////////////////////
//Create the queue.
////////////////////////////

dwFormatNameBufferLength = sizeof(wszFormatNameBuffer)/sizeof(wszFormatNameBuffer[0]);

hr = MQPathNameToFormatName((unsigned short*)Qname,wszFormatNameBuffer,&dwFormatNameBufferLength);

if (FAILED(hr))
{
MessageBox(NULL,"hr failed","RECIEVE",MB_OK);
}


if(hr==MQ_OK)
{
hr = MQOpenQueue(
wszFormatNameBuffer, // Format name of the queue
MQ_RECEIVE_ACCESS, // Access mode
MQ_DENY_NONE, // Share mode
&hQueue // OUT: Queue handle
);
//return hQueue;
}
else
{
hr = MQCreateQueue(
pSecurityDescriptor, // Security
&QueueProps, // Queue properties
wszFormatNameBuffer, // Output: Format Name
&dwFormatNameBufferLength // Output: Format Name length
);
}

MQMSGPROPS pmsgprops;
MQPROPVARIANT *paVariant;
MSGPROPID * paPropId;
DWORD dwcPropId = 0;

//
// The output parameters to an asynchronous call to MQReceiveMessage
// should be kept intact until the operation completes, you should
// not free or reuse them until the operation is complete.
//
//pmsgprops = new MQMSGPROPS;
paVariant = new MQPROPVARIANT[ 10];
paPropId = new MSGPROPID[ 10];


//////////////////////////////////////////////////
// Prepare the message properties to be retrieved.
/////////////////////////////////////////////////


// Set the PROPID_M_BODY property.
paPropId[dwcPropId] = PROPID_M_BODY; //PropId
paVariant[dwcPropId].vt = VT_VECTOR|VT_UI1; //Type
paVariant[dwcPropId].caub.cElems = MSG_BODY_LEN ; //Value
paVariant[dwcPropId].caub.pElems = new unsigned char[ MSG_BODY_LEN];

dwcPropId++;

////////////////////////////////
// Initialize the MQMSGPROPS structure
///////////////////////////////
pmsgprops.cProp = dwcPropId; //Number of properties
pmsgprops.aPropID = paPropId; //Ids of properties
pmsgprops.aPropVar = paVariant; //Values of properties
//pmsgProps->aStatus = NULL; //No Error report


///////////////////////////////////////////////
// Receive the message using callback function
// ReceiveCallbackRoutine.
///////////////////////////////////////////////

//hr = MQReceiveMessage(hQueue,100,MQ_ACTION_RECEIVE,pmsgprops,NULL,NULL,NULL,NULL);


hr = MQReceiveMessage(
hQueue, // Handle to the Queue
100, // Max time (msec) to wait
MQ_ACTION_RECEIVE, // Action
&pmsgprops, // Properties to retrieve
NULL, // No OVERLAPPED structure
NULL, // Callback function
NULL,
MQ_NO_TRANSACTION // No Cursor
);




// the following error is occured



if (FAILED(hr))
{
MessageBox(NULL,"Error","RECIEVE",MB_OK);
}





Regards
shakumar

shakumar

QuestionCInternetSession Assertion Failure Pin
İsmail Durmaz22-Dec-07 7:30
İsmail Durmaz22-Dec-07 7:30 
GeneralNamespace ATL Pin
Ju@ncho19-Dec-07 7:00
Ju@ncho19-Dec-07 7:00 
GeneralNeed to launch outlook Pin
SamuelHenderson18-Dec-07 5:37
SamuelHenderson18-Dec-07 5:37 
QuestionWhere did the WTL documentation project go? Pin
Perceptor18-Dec-07 3:33
Perceptor18-Dec-07 3:33 
GeneralA strange WTL-app debug/release problem [modified] Pin
T800G14-Dec-07 15:06
T800G14-Dec-07 15:06 
GeneralRe: A strange WTL-app debug/release problem Pin
CPallini28-Dec-07 11:45
mveCPallini28-Dec-07 11:45 
QuestionWTL COM? Pin
Kuryn13-Dec-07 23:17
Kuryn13-Dec-07 23:17 
AnswerRe: WTL COM? Pin
George L. Jackson14-Dec-07 4:44
George L. Jackson14-Dec-07 4:44 
GeneralRe: WTL COM? Pin
Kuryn15-Dec-07 18:12
Kuryn15-Dec-07 18:12 
GeneralRe: WTL COM? Pin
George L. Jackson16-Dec-07 14:23
George L. Jackson16-Dec-07 14:23 
AnswerRe: WTL COM? Pin
led mike18-Dec-07 5:29
led mike18-Dec-07 5:29 
AnswerRe: WTL COM? Pin
Michael Dunn5-Jan-08 20:36
sitebuilderMichael Dunn5-Jan-08 20:36 
GeneralWindows Service Help [modified] Pin
narayanagvs10-Dec-07 19:02
narayanagvs10-Dec-07 19:02 
GeneralRe: Windows Service Help Pin
myshketer11-Dec-07 21:21
myshketer11-Dec-07 21:21 
GeneralRe: Windows Service Help Pin
led mike12-Dec-07 6:29
led mike12-Dec-07 6:29 
GeneralSeeking advice on proper use of some c/c++ stuff, on my code. [modified] Pin
Dexterus6-Dec-07 0:49
Dexterus6-Dec-07 0:49 
GeneralRe: Seeking advice on proper use of some c/c++ stuff, on my code. [modified] Pin
Dexterus6-Dec-07 0:52
Dexterus6-Dec-07 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.