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 MQBeginTransaction function creates a Message Queuing internal transaction object that can be used to send messages to a queue or read messages from a queue.

HRESULT APIENTRY MQBeginTransaction(  
  ITransaction ** ppTransaction    


[out] Pointer to a pointer to the ITransaction interface for the new transaction object.


Indicates success.


There are no resources to create a new transaction.


Message Queuing could not enlist in the transaction.

The pointer returned by MQBeginTransaction can be used to set the pTransaction parameter of MQSendMessage or MQReceiveMessage.

When using an explicit internal transaction, make sure that the transact.h header file is included before mq.h. Transact.h provides the transaction object.

When using COM components, you can initiate a new Message Queuing internal transaction by calling the MSMQTransactionDispenser.BeginTransaction method, which returns a COM object that represents the new underlying transaction object.

For information onSee
Explicit internal transactionsMessage Queuing Internal Transactions
Implicit internal transactionsSingle-Message Transactions

The following code example is included in Using Message Queuing.

For a complete example ofSee
Sending a message using an internal transactionC/C++ Code Example: Sending a Message Using an Internal Transaction

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 Mq.h.

Library: Use Mqrt.lib.

Message Queuing Functions