Expand Minimize

Visual Basic Code Example: Retrieving MSMQQueueInfo.QueueGuid

This example provides a function that receives the path name of an existing public queue and returns the MSMQQueueInfo.QueueGuid property for it, which can be used to display the identifier of the queue.

To retrieve MSMQQueueInfo.QueueGuid

  1. Declare the objects needed to retrieve queue properties. This routine declares an MSMQQueueInfo object.

  2. Create the MSMQQueueInfo object. This example then uses MSMQQueueInfo.PathName to set the path name to the string passed to the function.

  3. Call MSMQQueueInfo.Refresh to obtain the current registered settings of the queue properties. Note that 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.

  4. Return the local setting of MSMQQueueInfo.QueueGuid.

Code Example

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

Function GetQueueGUID( _
                      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.
  ' Return the local value of MSMQQueueInfo.QueueGuid.
  GetQueueGUID = qinfo.QueueGuid
  Exit Function
  MsgBox "Error " + Hex(Err.Number) + " was returned." _
          + Chr(13) + Err.Description
End Function
© 2014 Microsoft. All rights reserved.