--------------------------------------------------------------------------------------
이미저장한 경우인지 확인방법
--------------------------------------------------------------------------------------
IMSMQQueuePtr pPeekQ = pInfo->Open(MQ_PEEK_ACCESS, MQ_DENY_NONE);
// 같은 항목이 존재하는지 확인한 후 삽입한다.
_variant_t vtTimeOut((long)1000); // 1 second until receive time-out
_variant_t bvtWantBody((bool)true); // Set to retrieve message body
_bstr_t bstrBody;
WCHAR strCur[MAX_PATH];
IMSMQMessagePtr pRetMsg(L"MSMQ.MSMQMessage");
pPeekQ->Reset();
pRetMsg = pPeekQ->PeekCurrent(&vtMissing, &bvtWantBody, &vtTimeOut );
while(pRetMsg != NULL)
{
ZeroMemory(strCur, sizeof(strCur));
bstrBody = pRetMsg->Body;
StringCchCopy(strCur, MAX_PATH, bstrBody);
if(memcmp(strCur, strMessage, nSize) == 0)
{
bExist = TRUE;
break;
}
pRetMsg = pPeekQ->PeekNext(&vtMissing, &bvtWantBody, &vtTimeOut);
}
pPeekQ->Close();
--------------------------------------------------------------------------------------
메세지큐에 등록된 갯수얻기
--------------------------------------------------------------------------------------
int nCount = 0;
QUEUEPROPID propId[1];
MQPROPVARIANT propVar[1];
HRESULT propStatus[1];
DWORD cprop = 0;
propId [cprop] = PROPID_MGMT_QUEUE_MESSAGE_COUNT;
propVar[cprop].vt = VT_NULL;
++cprop;
MQMGMTPROPS mqProps;
mqProps.cProp = cprop;
mqProps.aPropID = propId;
mqProps.aPropVar = propVar;
mqProps.aStatus = propStatus;
WCHAR wszFormatName[MAX_PATH] ={0};
WCHAR *wszFormatNamePrefix = L"queue=DIRECT=OS:";
StringCchPrintf(wszFormatName, MAX_PATH, L"%s%s\\%s", wszFormatNamePrefix, strPC, Queue);
HRESULT hr = MQMgmtGetInfo( strPC, wszFormatName, &mqProps );
if( FAILED( hr ) )
{
return 0;
}
else
{
return mqProps.aPropVar[0].ulVal;
}
return nCount;