Visual Basic Code Example: Retrieving MSMQQueueInfo.FormatName

 

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 MSMQQueueInfo.FormatName property, which can be used to display the format name of the queue.

This function can generate the format name of a local private queue, but it must retrieve information stored in the directory service to generate the format name of a local or remote public queue. This function cannot be used to obtain the format name of a remote private queue. For information on the different types of format names, see Format Names.

To retrieve MSMQQueueInfo.FormatName

  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. Return the local setting of MSMQQueueInfo.FormatName.

Code Example

The following code example requires MSMQ 3.0.

Function GetFormatName( _  
                       strPathname As String _  
                       ) As String  
  Dim qinfo As MSMQQueueInfo  
  
  ' Create the MSMQQueueInfo object.  
  Set qinfo = New MSMQQueueInfo  
  qinfo.PathName = strPathname  
  On Error GoTo ErrorHandler  
  
  'Return the local setting of MSMQQueueInfo.FormatName  
  GetFormatName = qinfo.FormatName  
  Exit Function  
  
ErrorHandler:  
  MsgBox "Error " + Hex(Err.Number) + " was returned." _  
          + Chr(13) + Err.Description  
End Function