Visual Basic Code Example: Retrieving MSMQQueueInfo.CreateTime
This example provides a function that receives the path name of an existing queue and returns the MSMQQueueInfo.CreateTime property for it, which can be used to display the date and time when the queue was created.
This function can use information stored on the local computer to return the date and time when a local private queue was created, but it must retrieve information stored in the directory service to return the date and time when a local or remote public queue was created. This function cannot be used to obtain the date and time when a remote private queue was created.
To retrieve MSMQQueueInfo.CreateTime
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 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.
Return the local setting of MSMQQueueInfo.CreateTime.
The following code example can be run on all versions of Message Queuing.
Function GetCreateTime( _ strPathname As String _ ) As Variant 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.CreateTime. GetCreateTime = qinfo.CreateTime Exit Function ErrorHandler: MsgBox "Error " + Hex(Err.Number) + " was returned." _ + Chr(13) + Err.Description End Function