Partager via


C-C++ Code Example: Retrieving PROPID_Q_JOURNAL_QUOTA

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

This example provides an application-defined function that retrieves the PROPID_Q_JOURNAL_QUOTA property of the journal of an existing queue and returns the quota to the caller.

This function can return the journal quota of a local private queue from information stored on the local computer, but must retrieve information stored in the directory service to return the journal quota of a local or remote public queue. This function cannot be used to obtain the journal quota of a remote private queue.

A direct format name can be passed to this function only for a local private queue.

For information on how Message Queuing uses the journal queue, see Target Journaling.

To retrieve PROPID_Q_JOURNAL_QUOTA

  1. Define the maximum number of queue properties to be specified and the queue property counter.

  2. Define the MQQUEUEPROPS structure.

  3. Specify PROPID_Q_JOURNAL_QUOTA.

  4. Initialize the MQQUEUEPROPS structure.

  5. Validate the input parameters provided by the caller.

  6. Call MQGetQueueProperties to retrieve the quota of the queue journal. If the call fails the returned error code is returned to the caller.

  7. Pass the retrieved queue journal quota to the caller on return.

Code Example

The following code example can be run on all versions of Message Queuing.

HRESULT GetQueueJournalQuotaProp(  
                                 LPCWSTR wszQueueFormatName,   
                                 ULONG *pulValue  
                                 )  
{  
  
  // Define the maximum number of queue properties and a property counter.  
  const int NUMBEROFPROPERTIES = 1;  
  DWORD cPropId=0;  
  
  // Define a queue property structure.  
  MQQUEUEPROPS   QueueProps;  
  QUEUEPROPID    aQueuePropId[NUMBEROFPROPERTIES];  
  MQPROPVARIANT  aQueuePropVar[NUMBEROFPROPERTIES];  
  HRESULT        aQueuePropStatus[NUMBEROFPROPERTIES];  
  HRESULT hr = MQ_OK;  
  
  // Specify the PROPID_Q_JOURNAL property.  
  aQueuePropId[cPropId] = PROPID_Q_JOURNAL_QUOTA; // Property ID  
  aQueuePropVar[cPropId].vt = VT_NULL;            // Type indicator  
  cPropId++;  
  
  // Initialize the MQQUEUEPROPS structure.  
  QueueProps.cProp = cPropId;  
  QueueProps.aPropID = aQueuePropId;  
  QueueProps.aPropVar = aQueuePropVar;  
  QueueProps.aStatus = aQueuePropStatus;  
  
  // Validate the input parameters .  
  if (wszQueueFormatName == NULL || pulValue == NULL)  
  {  
    return MQ_ERROR_INVALID_PARAMETER;  
  }  
  
  // Get the queue properties.  
  hr = MQGetQueueProperties(wszQueueFormatName, &QueueProps);  
  if (FAILED(hr))  
  {  
    return hr;  
  }  
  
  // Set the *pulValue parameter to pass the quota of the queue journal on return.  
  *pulValue = aQueuePropVar[0].ulVal;  
  return hr;  
}