Visual Basic Code Example: Retrieving MSMQQueueInfo.PathNameDNS
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.PathNameDNS property for it, which can be used to display the DNS path name of the queue.
Note that in this example, the local value of this property is not retrieved from the directory service. Message Queuing generates the DNS path name each time MSMQQueueInfo.PathNameDNS is retrieved. The DNS path name of a queue is not stored like other queue properties. This function cannot be used to obtain the DNS path name of a remote private queue.
To retrieve MSMQQueueInfo.PathNameDNS
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.
Return the local setting of MSMQQueueInfo.PathNameDNS.
Code Example
The following code example requires MSMQ 2.0 or greater.
Function GetQueuePathNameDNS( _
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 value of MSMQQueueInfo.PathNameDNS.
GetQueuePathNameDNS = qinfo.PathNameDNS
Exit Function
ErrorHandler:
MsgBox "Error " + Hex(Err.Number) + " was returned." _
+ Chr(13) + Err.Description
End Function