Visual Basic Code Example: Retrieving MSMQQueueInfo.MulticastAddress
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 a function that receives the path name of an existing queue and returns the PROPID_Q_MULTICAST_ADDRESS property for it, which can be used to display the multicast address associated with the queue.
This function can return the multicast address associated with a local private queue from information stored on the local computer, but must retrieve information stored in the directory service to return the multicast address associated with a local or remote public queue. This function cannot be used to obtain the multicast address associated with a remote private queue.
For information on how Message Queuing uses multicast addresses to send message to multiple destination queues, see Multiple-Destination Messaging.
To retrieve MSMQQueueInfo.MulticastAddress
Declare the objects needed to retrieve queue properties. This routine declares an MSMQQueueInfo object.
Create the MSMQQueueInfo object. This example then uses MSMQQueueInfo.PathName to set the path name to the string passed to the function
Call MSMQQueueInfo.Refresh to obtain the current registered settings of the queue properties.
Note
This call retrieves the settings of all properties of the queue with the path name set. If no such queue exists, an error message is displayed.
- Return the local setting of MSMQQueueInfo.MulticastAddress.
Code Example
The following code example requires MSMQ 3.0.
Function GetMulticastAddress( _
strPathname As String _
) As String
Dim qinfo As MSMQQueueInfo
' Create the MSMQQueueInfo object.
Set qinfo = New MSMQQueueInfo
qinfo.PathName = strPathname
On Error GoTo ErrorHandler
' Retrieve the internally registered property values.
qinfo.Refresh
' Return the local value of MSMQQueueInfo.MulticastAddress
GetMulticastAddress = qinfo.MulticastAddress
Exit Function
ErrorHandler:
MsgBox "Error " + Hex(Err.Number) + " was returned." _
+ Chr(13) + Err.Description
End Function