Updated: July 19, 2016

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

The Delete method of the MSMQQueueInfo object deletes an existing queue (it does not delete the MSMQQueueInfo object used to create the queue).

Sub Delete()  

This method has no parameters.

This method has no return values.

For information on return codes, see Message Queuing Error and Information Codes.

Before deleting a queue, your application must first obtain an MSMQQueueInfo object that represents the queue. This object can be returned by a query using the MSMQQuery.LookupQueue method or created by the sending or receiving application.

Before using an application-created MSMQQueueInfo object, the application must initialize it to reference the queue by setting its MSMQQueueInfo.PathName or MSMQQueueInfo.FormatName property. For public queues, setting the FormatName property with a cached public format name instead of the PathName property frees Message Queuing from the need to retrieve information stored in the directory service to generate this format name. Direct format names can be used only for local private queues.

Deleting the queue does not delete the MSMQQueueInfo object, only the existing reference to the queue in the directory service (for public queues) or the local computer (for private queues). You can still create a new queue based on the current properties of the MSMQQueueInfo object.

Applications that may be running offline cannot delete public queues while they are offline. Applications must have access to the directory service to delete a public queue. For information on offline operations, see Message Queuing Offline Support.

When a public queue is deleted, some clients may still see the queue registered in the directory service after the queue has been deleted. Changes to the directory service (such as deleting a public queue) are propagated from domain controller to domain controller, which can cause delays in the availability of new information. Consequently, clients using a specific domain controller may still try to send messages to the queue, even though it has been deleted. Propagation delays, including communication network delays such as down links, are controlled by the MSMQ Administrator.

Private queues cannot be deleted if they are registered on a remote computer. Only local private queues can be deleted.

Equivalent Function

With function calls, the equivalent function is MQDeleteQueue.

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.


Community Additions