Visual Basic Code Example: Setting MSMQQueueInfo.ServiceTypeGuid
This example provides a private Sub procedure that sets the MSMQQueueInfo.ServiceTypeGuid property of an existing queue based on a given service type identifier.
When Message Queuing updates the properties of a queue, their values are stored in one of two places. For public queues, these property values are stored in the directory service. For local private queues, these property values are stored on the local computer.
To set MSMQQueueInfo.ServiceTypeGuid
Declare the objects needed to update queue properties. This procedure 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.
Optional. Call MSMQQueueInfo.Refresh to obtain the current registered settings of the queue properties. Note that this call retrieves any changes made by other applications.
Set the MSMQQueueInfo.ServiceTypeGuid property.
Call MSMQQueueInfo.Update to register the new settings.
The following code example can be run on all versions of Message Queuing.
Sub SetServiceType( _ strPathname As String, _ strServiceType 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 ' Set the new service type GUID. qinfo.ServiceTypeGuid = strServiceType ' Update the internally registered property values. qinfo.Update MsgBox "A new service type GUID was set." Exit Sub ErrorHandler: MsgBox "Error " + Hex(Err.Number) + " was returned." _ + Chr(13) + Err.Description End Sub