Specifying Message Queuing Search Criteria
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
Message Queuing provides two structures that are used to specify the search criteria or restrictions for a query: MQPROPERTYRESTRICTION and MQRESTRICTION. The following example code shows how these two structures are used to define a single-restriction query based on the queue label.
MQPROPERTYRESTRICTION aPropRestriction[MAX_VAR];
MQRESTRICTION Restriction;
DWORD cRestriction = 0;
aPropRestiction[cRestriction].prop = PROPID_Q_LABEL;
aPropRestiction[cRestriction].rel = PREQ;
aPropRestiction[cRestriction].prval.vt = VT_LPWSTR;
aPropRestiction[cRestriction].prval.pwszVal = L"Test Queue";
cRestriction++;
Restriction.cRes = cRestriction;
Restriction.paPropRes = aPropRestriction;
Each MQPROPERTYRESTRICTION structure in the aPropRestiction array defines a single property, or restriction, that will be used in the search criteria. You can use any queue property except the path name (PROPID_Q_PATHNAME) as a search criterion. Also, you can specify a single restriction, as shown in the previous example code, or you can specify several restrictions for the query. For each restriction you must specify the following:
Queue property identifier. In the previous example code, the queue label is specified.
Comparison operator. You can use the following comparison operators: less than (PRLT), less than or equal to (PRLE), equal (PREQ), greater than or equal to (PRGE), and greater than (PRGT).
Queue property value. The property value is itself a structure. The first element in this structure is the variant type of the property and the second element is the value of the property.
The criterion in the previous example is "The queue's label is equal to the Unicode string 'Test Queue.'"
The MQRESTRICTION structure, on the other hand, specifies the number of restrictions used as search criteria and an array of those restrictions. In the previous example code, Restriction is an MQRESTRICTION structure that contains the count, cProps, in the cRes element and the array of restrictions, aPropRestiction, in the paPropRes element. Each element of this array is an MQPROPERTYRESTRICTION structure.
More Information
For information on | See |
---|---|
The structures used to specify which properties to retrieve | Specifying Queue Properties to Retrieve |
Example code for locating queues | Locating Queue Examples |